예제 #1
0
        public static string GetPersianFormat(DateTime mDate)
        {
            JalaliDate obj = new JalaliDate();
            int        Day, Year;

            Day = obj.GetDayOfMonth(mDate);
            string Month = PersianMonthNames[obj.GetMonth(mDate)];

            Year = obj.GetYear(mDate);
            return(string.Format("{2}    {1}  {0}", Year, Month, Day));
        }
예제 #2
0
        public static string GetJalaliDateTime(DateTime date)
        {
            JalaliDate obj = new JalaliDate();
            int        Day, Month, Year, minute, hour;

            Day    = obj.GetDayOfMonth(date);
            Month  = obj.GetMonth(date);
            Year   = obj.GetYear(date);
            hour   = obj.GetHour(date);
            minute = obj.GetMinute(date);
            return(string.Format("{0}/{1}/{2} {3}:{4}", Year, Month, Day, hour, minute));
        }
예제 #3
0
        public static string GetJalaliDate(String MiladyDate, bool SmallDate)
        {
            DateTime Date = Convert.ToDateTime(MiladyDate);

            Date = Date.AddHours(DeffrenceTime);
            if (SmallDate)
            {
                return(GetJalaliDate(Date, "/"));
            }
            else
            {
                JalaliDate obj = new JalaliDate();

                return(obj.GetStringJalaliDate(Date));
            }
        }
예제 #4
0
        public static string GetJalaliDate(DateTime MiladyDate, string Seprator, string Direction, bool IsIntelligent)
        {
            int Day, Month, Year;

            MiladyDate = MiladyDate.AddHours(DeffrenceTime);
            JalaliDate obj = new JalaliDate();

            Day   = obj.GetDayOfMonth(MiladyDate);
            Month = obj.GetMonth(MiladyDate);
            Year  = obj.GetYear(MiladyDate);
            if (IsIntelligent)
            {
                TimeSpan difference = DateTime.Now - MiladyDate;
                if (difference.Days == 0)
                {
                    return("امروز");
                }
                if (difference.Days == 1)
                {
                    return("دیروز");
                }
            }
            if (Direction == "ltr")
            {
                //return Year + Seprator + (Month<10 ? "0" +Month.ToString():Month.ToString()) + Seprator +(Day<10 ? "0" +Day.ToString():Day.ToString());
                return
                    ((Day < 10 ? "0" + Day : Day.ToString()) + Seprator +
                     (Month < 10 ? "0" + Month : Month.ToString()) + Seprator + Year);
            }
            else
            {
                return
                    (Year + Seprator + (Month < 10 ? "0" + Month : Month.ToString()) + Seprator +
                     (Day < 10 ? "0" + Day : Day.ToString()));
            }
        }
예제 #5
0
        public static string GetJalaliDate(DateTime MiladyDate, string Seprator, string Direction)
        {
            int Day, Month, Year;

            MiladyDate = MiladyDate.AddHours(DeffrenceTime);
            JalaliDate obj = new JalaliDate();

            Day = obj.GetDayOfMonth(MiladyDate);

            Month = obj.GetMonth(MiladyDate);
            Year  = obj.GetYear(MiladyDate);
            if (Direction == "ltr")
            {
                return
                    ((Day < 10 ? "0" + Day : Day.ToString()) + Seprator +
                     (Month < 10 ? "0" + Month : Month.ToString()) + Seprator + Year);
            }
            else
            {
                return
                    (Year + Seprator + (Month < 10 ? "0" + Month : Month.ToString()) + Seprator +
                     (Day < 10 ? "0" + Day : Day.ToString()));
            }
        }