Parsi Coders
تاریخ فارسی بکمک C# - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: C# Programming (http://parsicoders.com/forumdisplay.php?fid=55)
+--- موضوع: تاریخ فارسی بکمک C# (/showthread.php?tid=249)



تاریخ فارسی بکمک C# - Ghoghnus - 05-10-2011

سلام دوستان به کمک این کد میشه به راحتی و بدونه هیچ فایل اضافه ای تاریخ میلادی را به شمسی تبدیل کرد

کد:
using System.Globalization;
PersianCalendar p = new PersianCalendar();
            string day, mon, year, wday; long s;
            day = p.GetDayOfMonth(DateTime.Now) + "";
            mon = p.GetMonth(DateTime.Now) + "";
            year = p.GetYear(DateTime.Now) + "";
            wday = p.GetDayOfWeek(DateTime.Now) + "";
            s = Convert.ToInt64(day);

            if (s < 10) day = "0" + day;
            s = Convert.ToInt64(mon);
            if (s < 10) mon = "0" + mon;
            if (wday == "Thursday")
            {
                wday = "پنج شنبه";
                
            }
            if (wday == "Friday")
            {
                wday = "آدینه";
            
            }
            if (wday == "Saturday")
            {
                wday = "شنبه";
            
            }
            if (wday == "Sunday")
            {
                wday = "یک شنبه";
                .
            }
            if (wday == "Monday")
            {
                wday = "دو شنبه";
            
            }
            if (wday == "Tuesday")
            {
                wday = "سه شنبه";
              
            }
            if (wday == "Wednesday")
            {
                wday = "چهار شنبه";
            
            }
            
            nDay = year + "/" + mon + "/" + day;

            text1.Text = "امروز=" + wday + "   مورخ   " + year + "/" + mon + "/" + day;