Пример #1
0
        public void CheckToLongStringHM()
        {
            var    d1   = new PersianDateTime(1399, 12, 30, 23, 59).ToLongStringHM().Replace(" ", "");
            string time = "ساعت بیست و سه و پنجاه و نه دقیقه".Replace(" ", "");

            Assert.Equal(time, d1);
        }
Пример #2
0
        public void When_GetPersianDatesDiff_Expect_NumberEqualDiff()
        {
            var dt1 = new PersianDateTime("1399/12/29");
            var dt2 = new PersianDateTime("1399/11/29");

            Assert.Equal(30, Convert.ToInt32(PersianDateExtensions.DateDifference(dt1, dt2)));
        }
Пример #3
0
        public void When_CreateDateTimeWithIntCtorAndStringCtor_Expect_DateTimesAreEqual2()
        {
            var dt1 = new PersianDateTime(1399, 12, 29, 23, 30, 10);
            var dt2 = new PersianDateTime("1399/12/29 23:30:10");

            Assert.Equal(dt1, dt2);
        }
Пример #4
0
        public void When_CreateEndTimeOfDay_Expect_TimeIs235959()
        {
            var             dt1 = new PersianDateTime("1399/12/29 23:30:20").ShamsiEndDateTimeOfDay();
            PersianDateTime dt2 = new(1399, 12, 29, 23, 59, 59, 999);

            Assert.Equal(dt1, dt2);
        }
Пример #5
0
        public void CheckDateDiff()
        {
            var dt1 = new PersianDateTime("1399/12/29");
            var dt2 = new PersianDateTime("1399/11/29");

            Assert.Equal(30, Convert.ToInt32(PersianDateTime.DateDifference(dt1, dt2)));
        }
Пример #6
0
        public void When_ConvertTimeToString_Expect_HourMinuteStringIsOk()
        {
            var    d1   = new PersianDateTime(1399, 12, 30, 23, 59).ToLongStringHM().Replace(" ", "");
            string time = "ساعت بیست و سه و پنجاه و نه دقیقه".Replace(" ", "");

            Assert.Equal(time, d1);
        }
Пример #7
0
        public void CheckTwoConstructor2()
        {
            var dt1 = new PersianDateTime("1399/12/29 23:30");
            var dt2 = new PersianDateTime("1399/12/29 23:30:00");

            Assert.Equal(dt1, dt2);
        }
Пример #8
0
        public void CheckStartOfDay()
        {
            var             dt1 = PersianDateTime.StartOfDay(new PersianDateTime("1399/12/29 23:30:20"));
            PersianDateTime dt2 = new PersianDateTime("1399/12/29 00:00:00");

            Assert.Equal(dt1, dt2);
        }
Пример #9
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            TxtUserName.Focus();
            DUserLogin.SetSecurityAccess();
            if (!(DUserLogin.SecurityAccess(ref _counter) >= 5))
            {
                _getDate                  = DUserLogin.Date();
                BtnLogin.IsEnabled        = false;
                _dispatcherTimer.Tick    += dispatcherTimer_Tick;
                _dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
                _dispatcherTimer.Start();
            }

            var adminRegistered = DUserLogin.ChekAdminRegistered();

            if (adminRegistered != null && (bool)adminRegistered)
            {
                return;
            }
            Hide();
            var winAddAdmin = new WinAddAdmin();

            winAddAdmin.ShowDialog();
            var chekAdminRegistered = DUserLogin.ChekAdminRegistered();

            if (chekAdminRegistered != null && (bool)chekAdminRegistered)
            {
                Show();
            }
        }
Пример #10
0
        public void moharram_1399()
        {
            var d1  = new PersianDateTime(1401, 5, 16);
            var str = d1.GetDateData();

            Assert.True(d1.IsHoliDay && d1.DateMetaDatas.Any(d => d.DateType == DateType.HoliDay));
        }
Пример #11
0
        public ActionResult AddLate(LateClassDto lateDto)
        {
            if (lateDto.studentID != null)
            {
                var persianDate = PersianDateTime.Parse(lateDto.lateDate);

                var late = new Late
                {
                    StudentID = Convert.ToInt32(lateDto.studentID),
                    LateDate  = persianDate.ToDateTime(),
                    LateTime  = Convert.ToInt32(lateDto.howMuch),
                    Problem   = lateDto.problem,
                    IsTrue    = lateDto.isTrue
                };

                try
                {
                    _context.Lates.Add(late);
                    _context.SaveChanges();
                    ModelState.Clear();
                    return(Content("اطلاعات وارد شد"));
                }
                catch (Exception exc)
                {
                    throw;
                }
            }
            else
            {
                return(Content("صحیح نمیباشد"));
            }
        }
Пример #12
0
        public JsonResult getStudyEvaluation()
        {
            // Initialization.
            var thisYear = new PersianDateTime(PersianDateTime.Now.Year, 01, 01);

            JsonResult result = new JsonResult();

            try
            {
                var data         = db.Borrows.Select(b => new { BorrowingDate = b.BorrowingDate }).ToList().AsEnumerable();
                var thisYearData = (from b in data
                                    select new
                {
                    BorrowingDate = (PersianDateTime.Parse(b.BorrowingDate))
                }
                                    ).Where(b => b.BorrowingDate >= thisYear).ToList();
                var groupByMonth = (from b in thisYearData group b by b.BorrowingDate.Month into mData
                                    select new { monthNo = mData.Key, monthRecords = mData.Count() }).ToList();

                return(Json(new { data = groupByMonth },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            return(result);
        }
Пример #13
0
        public void PersianDateTimeTests()
        {
            //PersianDateTime is utility data type for GregorianDateTime to/from PersianDateTime conversions.

            var pNow = PersianDateTime.Now;

            var clrDate = DateTime.Now;
            //Convert an instance of CLR-DateTime to PersianDateTime
            PersianDateTime faDateTime = clrDate.ToPersianDateTime();

            //Convert an instance of PersianDateTime to CLR-DateTime
            clrDate = faDateTime.ToDateTime();

            Debug.WriteLine(faDateTime.Hour12);      // Hour based on 12Hours
            Debug.WriteLine(faDateTime.IsAfternoon); // ...

            //Convert persian date time string to PersianDateTime
            faDateTime = PersianDateTime.Parse("1395/10/1 5:1 ب.ظ");

            //writes name of week day
            Debug.WriteLine("MonthName: {0}\nDayName: {1}", faDateTime.MonthName, faDateTime.DayName);

            //well form date time display :-)
            Debug.WriteLine(PersianDateTime.Parse("1395/10/19").ToString("dddd d MMMM yyyy")); // یکشنبه 19 دی 1395

            Debugger.Break();
        }
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            if (bindingContext.ModelName.EndsWith("Date") &&
                (bindingContext.ModelType == typeof(long) || bindingContext.ModelType == typeof(long?)))
            {
                ValueProviderResult valueResult = null;

                valueResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
                if (valueResult == null)
                {
                    return(null);
                }

                string          stringValue = (string)valueResult.ConvertTo(typeof(string));
                PersianDateTime persianDateTime;
                if (PersianDateTime.TryParse(stringValue, out persianDateTime))
                {
                    return(persianDateTime.ToLong());
                }
                else
                {
                    long value = 0;
                    if (long.TryParse(stringValue, out value))
                    {
                        return(value);
                        //return PersianDateTime.FromLong(value);
                    }
                }
                return(null);
            }

            return(base.BindModel(controllerContext, bindingContext));
        }
Пример #15
0
        /// <summary>
        /// آخر سال شمسی را برمیگرداند
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public DateTime GetEndOfPersianYear(DateTime date)
        {
            PersianDateTime pd        = new PersianDateTime(date);
            DateTime        endOfYear = Utility.Utility.ToMildiDate(String.Format("{0}/12/{1}", pd.Year, Utility.Utility.GetEndOfPersianMonth(pd.Year, 12)));

            return(endOfYear);
        }
        public JsonResult Edit(EditInvoiceViewModel viewModel)
        {
            var invoice = new Invoice
            {
                Id         = viewModel.Id,
                Number     = viewModel.Number,
                CustomerId = viewModel.CustomerId,
                CreatedOn  = PersianDateTime.Parse(viewModel.CreatedOnString).ToDateTime(),
                Version    = viewModel.Version
            };

            invoice.Items = new List <InvoiceItem>();
            foreach (var item in viewModel.Items)
            {
                var invoiceItem = new InvoiceItem
                {
                    Id        = item.Id,
                    ProductId = item.ProductId,
                    Price     = item.Price,
                    Quantity  = item.Quantity,
                    InvoiceId = item.InvoiceId
                };
                invoice.Items.Add(invoiceItem);
            }
            try
            {
                ServiceFactory.Create <IInvoiceService>().UpdateInvoice(invoice);
                return(Json(new { success = true }));
            }
            catch (DbUpdateConcurrencyException)
            {
                // ModelState.AddModelError("", "این فاکتور قبلا در سیستم توسط فرد دیگری ویرایش شده است.صفحه را رفرش کنید.");
                return(Json(new { success = false }));
            }
        }
Пример #17
0
        /// <summary>
        /// سقف اضافه کار مجاز در نیمه اول و دوم سال
        /// </summary>
        /// <param name="MyRule"></param>
        public void R6502(AssignedRule MyRule)
        {
            //4005 اضافه کار مجاز ماهانه
            //اضافه کار غیر مجاز ماهانه  4006
            //3 کارکرئناخالص ماهانه
            GetLog(MyRule, DebugRuleState.Before, 4005, 4006, 3);
            int             maxOverworkHalf1 = MyRule["First", this.RuleCalculateDate].ToInt();
            int             maxOverworkHalf2 = MyRule["Second", this.RuleCalculateDate].ToInt();
            PersianDateTime pd = Utility.ToPersianDateTime(this.RuleCalculateDate);

            if (pd.Month <= 6)//نیمه اول سال
            {
                if (this.DoConcept(4005).Value > maxOverworkHalf1)
                {
                    this.DoConcept(4006).Value += this.DoConcept(4005).Value - maxOverworkHalf1;
                    this.DoConcept(3).Value    -= this.DoConcept(4005).Value - maxOverworkHalf1;
                    this.DoConcept(4005).Value  = maxOverworkHalf1;
                }
            }
            else
            {
                if (this.DoConcept(4005).Value > maxOverworkHalf2)
                {
                    this.DoConcept(4006).Value += this.DoConcept(4005).Value - maxOverworkHalf2;
                    this.DoConcept(3).Value    -= this.DoConcept(4005).Value - maxOverworkHalf2;
                    this.DoConcept(4005).Value  = maxOverworkHalf2;
                }
            }
            GetLog(MyRule, DebugRuleState.After, 4005, 4006, 3);
        }
Пример #18
0
        public void CheckWorkingDays()
        {
            var d1 = new PersianDateTime(1397, 8, 1);
            var d2 = new PersianDateTime(1397, 8, 30);

            Assert.Equal(20, PersianDateTime.GetWorkingDays(d1, d2));
        }
        public BusinessProfile()
        {
            PersianDateTime tester;

            CreateMap <BusinessViewModel, Business>()
            .ForMember(d => d.Location, s => s.MapFrom(mf => mf.Latitude.HasValue && mf.Longitude.HasValue ? SqlGeography.Point(mf.Latitude.Value, mf.Longitude.Value, 4326) : SqlGeography.Point(0, 0, 4326)))
            .ForMember(d => d.CreatedAt, s => s.MapFrom(mf => PersianDateTime.TryParse(mf.CreatedAt, out tester, @"/") ? PersianDateTime.Parse(mf.CreatedAt, @"/").ToDateTime() : (DateTime?)null))
            .ForMember(d => d.UpdatedAt, s => s.MapFrom(mf => PersianDateTime.TryParse(mf.UpdatedAt, out tester, @"/") ? PersianDateTime.Parse(mf.UpdatedAt, @"/").ToDateTime() : (DateTime?)null))
            .ForMember(d => d.EvidenceStatusId, s => s.MapFrom(mf => mf.EvidenceStatusId.HasValue ? (byte)mf.EvidenceStatusId : (byte?)null))
            .ForMember(d => d.Status, s => s.MapFrom(mf => mf.Status.HasValue ? (byte)mf.Status : (byte?)null))
            .ForMember(d => d.ChangeRequest, s => s.MapFrom(mf => mf.ChangeRequest.HasValue?(byte)mf.ChangeRequest:(byte?)null))
            .ForMember(d => d.AvailabilityStatusId, s => s.MapFrom(mf => mf.AvailabilityStatusId.HasValue ? (byte)mf.AvailabilityStatusId : (byte?)null));

            CreateMap <Business, BusinessViewModel>()
            .ForMember(d => d.Latitude, s => s.MapFrom(mf => mf.Location != null ? (double)mf.Location.Lat : (double?)null))
            .ForMember(d => d.Longitude, s => s.MapFrom(mf => mf.Location != null ? (double)mf.Location.Long : (double?)null))
            .ForMember(d => d.CreatedAt, s => s.MapFrom(mf => mf.CreatedAt != null ? new PersianDateTime(mf.CreatedAt).ToString() : string.Empty))
            .ForMember(d => d.UpdatedAt, s => s.MapFrom(mf => mf.UpdatedAt != null ? new PersianDateTime(mf.UpdatedAt).ToString() : string.Empty))
            .ForMember(d => d.EntityHasChanged, s => s.MapFrom(mf => mf.LastEntityData != null ? true : false))
            .ForMember(d => d.CategoryHasChanged, s => s.MapFrom(mf => mf.LastCategoryData != null ? true : false))
            .ForMember(d => d.FacilityHasChanged, s => s.MapFrom(mf => mf.LastFacilityData != null ? true : false))
            .ForMember(d => d.Status, s => s.MapFrom(mf => mf.Status != null ? (GeneralEnums.Status)mf.Status : (GeneralEnums.Status?)null))
            .ForMember(d => d.ChangeRequest, s => s.MapFrom(mf => mf.ChangeRequest != null?(EditStatus)mf.ChangeRequest:(EditStatus?)null))
            .ForMember(d => d.StatusTitle, s => s.MapFrom(mf => mf.Status.HasValue ? EnumHelper <GeneralEnums.Status> .GetDisplayValue((GeneralEnums.Status)mf.Status) : string.Empty))
            .ForMember(d => d.EvidenceStatusId, s => s.MapFrom(mf => mf.EvidenceStatusId != null ? (GeneralEnums.EvidenceStatusType)mf.EvidenceStatusId : (GeneralEnums.EvidenceStatusType?)null))
            .ForMember(d => d.EvidenceStatusTitle, s => s.MapFrom(mf => mf.EvidenceStatusId.HasValue ? EnumHelper <GeneralEnums.EvidenceStatusType> .GetDisplayValue((GeneralEnums.EvidenceStatusType)mf.EvidenceStatusId) : string.Empty))
            .ForMember(d => d.AvailabilityStatusId, s => s.MapFrom(mf => mf.AvailabilityStatusId != null ? (GeneralEnums.AvilabilityStatus)mf.AvailabilityStatusId : (GeneralEnums.AvilabilityStatus?)null))
            .ForMember(d => d.AvailabilityStatusTitle, s => s.MapFrom(mf => mf.AvailabilityStatusId.HasValue ? EnumHelper <GeneralEnums.AvilabilityStatus> .GetDisplayValue((GeneralEnums.AvilabilityStatus)mf.AvailabilityStatusId) : string.Empty))
            .ForMember(d => d.ServiceRequest2BusinessStatusTitle, s => s.MapFrom(mf => mf.ServiceRequest2BusinessStatus.HasValue ? EnumHelper <GeneralEnums.ServiceRequest2BusinessStatusType> .GetDisplayValue((GeneralEnums.ServiceRequest2BusinessStatusType)mf.ServiceRequest2BusinessStatus) : string.Empty))
            .ForMember(d => d.GenderTypeId, s => s.MapFrom(mf => mf.GenderTypeId != null ? (GeneralEnums.Gender)mf.GenderTypeId : (GeneralEnums.Gender?)null))
            .ForMember(d => d.GenderTypeString, s => s.MapFrom(mf => mf.GenderTypeId.HasValue ? EnumHelper <GeneralEnums.Gender> .GetDisplayValue((GeneralEnums.Gender)mf.GenderTypeId) : string.Empty));


            CreateMap <XmlBusiness, Business>();
        }
Пример #20
0
        public void CheckTwoConstructor()
        {
            PersianDateTime dt1 = new PersianDateTime(1399, 10, 13);
            PersianDateTime dt2 = new PersianDateTime("1399/10/13");

            Assert.Equal(dt1, dt2);
        }
Пример #21
0
        public static DateTime ToMiladiDate(this string dt)
        {
            PersianCalendar pc = new PersianCalendar();
            PersianDateTime st = new PersianDateTime(Convert.ToDateTime(dt));

            return(pc.ToDateTime(st.Year, st.Month, st.Day, st.Hour, st.Minute, 0, 0));
        }
Пример #22
0
        public void CheckTwoConstructor3()
        {
            var dt1 = new PersianDateTime(1399, 12, 29, 23, 30, 10);
            var dt2 = new PersianDateTime("1399/12/29 23:30:10");

            Assert.Equal(dt1, dt2);
        }
Пример #23
0
        public List <PostModel> Posttable()
        {
            var  res = new List <PostModel>();
            PDBC db  = new PDBC("PandaMarketCMS", true);

            db.Connect();

            DataTable dt = db.Select("SELECT [Id],[Title],[GroupId],[Text_min],[Text],(SELECT [ad_firstname]+ ' '+ [ad_lastname] as name FROM [tbl_ADMIN_main]where id_Admin=[WrittenBy_AdminId])as adminName ,[Date],[IsImportant],[Is_Deleted],[Is_Disabled],(SELECT [name]FROM [tbl_BLOG_Categories] where Id=[Cat_Id]) as Category,(SELECT [name]FROM [tbl_BLOG_Groups] where G_Id=[GroupId]) as GroupName,(SELECT top 1 B.PicAddress FROM [tbl_BLOG_Pic_Connector] as A inner join [tbl_ADMIN_UploadStructure_ImageAddress] as B on A.[PicId]=B.PicID where A.PostId=Id)as Pic FROM [tbl_BLOG_Post] order by(date)desc");

            db.DC();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DateTime        date            = Convert.ToDateTime(dt.Rows[i]["Date"]);
                PersianDateTime persianDateTime = new PersianDateTime(date);
                var             model           = new PostModel()
                {
                    Id              = Convert.ToInt32(dt.Rows[i]["Id"]),
                    by              = dt.Rows[i]["adminName"].ToString(),
                    Category        = dt.Rows[i]["Category"].ToString(),
                    InGroup         = dt.Rows[i]["GroupName"].ToString(),
                    ImagePath       = AppendServername(dt.Rows[i]["Pic"].ToString()),
                    IsDeleted       = Convert.ToInt32(dt.Rows[i]["Is_Deleted"]),
                    IsDisabled      = Convert.ToInt32(dt.Rows[i]["Is_Disabled"]),
                    text            = dt.Rows[i]["Text"].ToString(),
                    title           = dt.Rows[i]["Title"].ToString(),
                    text_min        = dt.Rows[i]["Text_min"].ToString(),
                    date            = persianDateTime.ToLongDateString(),
                    GPIDforPostPAge = dt.Rows[i]["GroupId"].ToString()
                };
                res.Add(model);
            }
            return(res);
        }
Пример #24
0
        public void CheckEndOfDay()
        {
            var             dt1 = PersianDateTime.EndOfDay(new PersianDateTime("1399/12/29 23:30:20"));
            PersianDateTime dt2 = new PersianDateTime(1399, 12, 29, 23, 59, 59, 999);

            Assert.Equal(dt1, dt2);
        }
Пример #25
0
        protected void Button8_Click(object sender, EventArgs e)
        {
            PersianDateTime   dt = new PersianDateTime(DateTime.Now);
            BEngineCalculator pb = new BEngineCalculator();

            pb.Calculate(32687, "1391/06/01", "1392/01/01", false);
        }
Пример #26
0
        public async Task <Dictionary <string, int> > GetLossCountLastDaysAsync(int dayCount = 10)
        {
            var fromDate = DateTime.Now.AddDays(-dayCount);
            var result   = new Dictionary <string, int>();

            var userCount = await _dbSet.AsNoTracking().Where(x => x.InsertDateMi >= fromDate)
                            .GroupBy(x => x.InsertDateSh)
                            .Select(g => new
            {
                Date  = g.Key,
                Count = g.Count()
            }).ToListAsync();

            for (int i = dayCount - 1; i >= 0; i--)
            {
                var date      = PersianDateTime.Parse(DateTime.Now.AddDays(-i)).ToString(PersianDateTimeFormat.Date);
                var statistic = userCount.FirstOrDefault(x => x.Date == date);
                if (statistic != null)
                {
                    result.Add(date, statistic.Count);
                }
                else
                {
                    result.Add(date, 0);
                }
            }

            return(result);
        }
Пример #27
0
        public void CheckToLongStringHMS()
        {
            var    d1   = PersianDateTime.EndDateOfMonth(1399, 12).ToLongStringHMS().Replace(" ", "");
            string time = "ساعت بیست و سه و پنجاه و نه دقیقه و پنجاه و نه ثانیه".Replace(" ", "");

            Assert.Equal(time, d1);
        }
Пример #28
0
        public void When_ConvertDateToString_Expect_DayMonthYearStringIsOk()
        {
            var    d1   = new PersianDateTime(1397, 7, 27).ToLongStringYMD().Replace(" ", "");
            string time = "جمعه بیست و هفت مهر سال یکهزار و سیصد و نود و هفت".Replace(" ", "");

            Assert.Equal(time, d1);
        }
Пример #29
0
        public void When_CreateStartTimeOfDay_Expect_TimeIsZero()
        {
            var             dt1 = new PersianDateTime("1399/12/29 23:30:20").ShamsiStartDateTimeOfDay();
            PersianDateTime dt2 = new("1399/12/29 00:00:00");

            Assert.Equal(dt1, dt2);
        }
Пример #30
0
        public void CheckToLongStringYMD()
        {
            var    d1   = new PersianDateTime(1397, 7, 27).ToLongStringYMD().Replace(" ", "");
            string time = "جمعه بیست و هفت مهر سال یکهزار و سیصد و نود و هفت".Replace(" ", "");

            Assert.Equal(time, d1);
        }
Пример #31
0
        public static string MakeCalender(int year)
        {
            if (year == 0)
            {
                year = new PersianDateTime(DateTime.Now).Year;
            }
            var persiandate = new PersianDateTime(year, 1, 1);
            string res = "";
            for (int i = 1; i < 5; i++)
            {
                res += "<div class='row'>";
                for (int j = 1; j < 4; j++)
                {

                    res += "<div class='col-md-4' style='text-align: center'>";
                    res += "<div class='cal'>";
                    res += " <table class='cal-table'>";
                    res += "<caption class='cal-caption'>";
                    res += persiandate.GetLongMonthName;
                    //res += monthCounter.ToString();
                    res += "</caption>";
                    res += "<tbody class='cal-body'>";
                    int emptyCells = ((int)persiandate.DayOfWeek + 7 - 6) % 7;
                    int days = persiandate.GetMonthDays;
                    for (int k = 0; k != 42; k++)
                    {
                        if (k % 7 == 0)
                        {
                            res += "<tr>";
                            if (k > 0) res += "</tr>";
                        }

                        if (k < emptyCells || k >= emptyCells + days)
                        {
                            res += "<td class='cal-off'><a href='#'>";
                            res += "-";
                            res += "</a></td>";
                        }
                        else
                        {
                            if (!string.IsNullOrWhiteSpace(TodayVM.GetPersianEvent(persiandate.Month, persiandate.Day)))
                                res += "<td title='" + TodayVM.GetPersianEvent(persiandate.Month, persiandate.Day)
                                       + "'" + " class='cal-check'>";
                            else
                            {
                                if (persiandate.ToDateTime().Date == DateTime.Now.Date)
                                    res += "<td class='cal-today'>";
                                else
                                    res += "<td >";
                            }

                            if (persiandate.DayOfWeek == DayOfWeek.Friday)
                                res += "<a style='color:red;'>";
                            else
                                res += "<a>";


                            var dayNo = "12";
                            res += TodayVM.ToPersianDigit(persiandate.Day.ToString());
                            res += "</a></td>";
                            persiandate = persiandate.AddDays(1);
                        }
                    }
                    res += "</tbody>";
                    res += "</table>";
                    res += "</div>";
                    res += "</div>";
                    persiandate.AddMonths(1);
                }
                res += "</div>";
            }
            return res;
        }
Пример #32
0
 public PlanningVM(DateTime date)
 {
     Date = date.ToLongDateString();
     PersianDate=new PersianDateTime(date).ToLongDateString();
     ArabicDate = date.ToString("dddd،d MMMM yyyy", new CultureInfo("ar-SA"));
 }
Пример #33
0
		private static void Test1()
		{
			PersianDateTime persianDateTime = PersianDateTime.Parse("1394/02/02 12:40:50:312");
			persianDateTime.EnglishNumber = true;
			string serializedPersianDateTime = JsonConvert.SerializeObject(persianDateTime);

			var persianDateTime2 = PersianDateTime.Parse(13901229);
			var dateTIme1 = persianDateTime2.ToDateTime();
			Console.WriteLine(dateTIme1.Equals(persianDateTime2));

			PersianDateTime persianDateTime1 = JsonConvert.DeserializeObject<PersianDateTime>(serializedPersianDateTime);
			Console.WriteLine(persianDateTime1.ToString("yyyy/MM/dd   HH:mm:ss:fff"));

			persianDateTime = PersianDateTime.Parse(13901229);
			persianDateTime.EnglishNumber = true;
			persianDateTime = persianDateTime.AddDays(2);
			Console.WriteLine(persianDateTime);

			persianDateTime = PersianDateTime.Parse("چهارشنبه، ۱۰ دی ۱۳۹۳ ۱۲:۳۸");
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime);

			persianDateTime = PersianDateTime.Parse("دوشنبه 24 آذر 1393 ساعت 3:59:3 ب.ظ");
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime);

			persianDateTime = PersianDateTime.Parse("24 آذر 1393");
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime);

			persianDateTime = PersianDateTime.Parse("د 24 آذر 1393 4:2:5:5 ب.ظ");
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime);

			persianDateTime = PersianDateTime.Parse("1393/02/01");
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime);

			persianDateTime = PersianDateTime.Parse("1393/02/01 02:03");
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime);

			persianDateTime = PersianDateTime.Parse("1393/02/01 02:03:10:30");
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime);

			persianDateTime = PersianDateTime.Parse("93/1/1 3:15 ب.ظ");
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime);

			persianDateTime = PersianDateTime.Parse("جمعه 93/2/1 ساعت 3:2 ب.ظ");
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime);

			persianDateTime = new PersianDateTime(DateTime.Now.AddDays(-8)) { EnglishNumber = true };
			string timeFromNow = persianDateTime.ElapsedTime();
			Console.WriteLine(timeFromNow);

			persianDateTime = PersianDateTime.Today;
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime.GetWeekOfMonth);
			Console.WriteLine(persianDateTime.GetWeekOfYear);

			persianDateTime = PersianDateTime.Now;
			persianDateTime.EnglishNumber = true;
			Console.WriteLine(persianDateTime.Date);

			persianDateTime = new PersianDateTime(1394, 5, 9);
			Console.WriteLine(persianDateTime.Date);

			persianDateTime = new PersianDateTime(1394, 5, 9);
			Console.WriteLine(PersianDateTime.Now.Subtract(persianDateTime));

			// Test IComparable

			Console.WriteLine();
			Console.WriteLine("--------------------");
			Console.WriteLine();

			List<PersianDateTime> persianDateTimes = new List<PersianDateTime>();
			for (int i = 0; i < 5; i++)
			{
				persianDateTime = new PersianDateTime(DateTime.Now)
				{
					EnglishNumber = true
				}.AddDays(i).AddMinutes(i);
				persianDateTimes.Add(persianDateTime);
			}
			persianDateTimes = persianDateTimes.OrderByDescending(q => q).ToList();

			foreach (PersianDateTime item in persianDateTimes)
				Console.WriteLine(item);

		}