private void NumQuickDateIdent(int num) { if (Peek(2).Kind == TokenKind.AGO) { num = num * -1; } switch (Peek(1).Kind) { case TokenKind.DAY_IDENTIFIER: DayDateIdent(Peek(1).Text, TokenKind.NEXT); Load(); break; case TokenKind.DAY: _dateRange.AddDate(Today.AddDays(num)); Load(); break; case TokenKind.WEEK: _dateRange.AddDate(Today.AddDays(num * 7)); Load(); break; case TokenKind.MONTH: _dateRange.AddDate(Today.AddMonths(num)); Load(); break; case TokenKind.YEAR: _dateRange.AddDate(Today.AddYears(num)); Load(); break; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { dtExpireDate.MinDate = Today; dtExpireDate.SelectedDate = Today.AddDays(txtDuration.Value.Value * 7); LoadBreadCrumbs(); } }
public AttendanceController(IUnitOfWork _unitOfWork, IConfiguration configuration) : base(_unitOfWork) { _configuration = configuration; Now = BaseHelper.UserGeo().UserDateTime; Today = Now.Date; Tommorow = Today.AddDays(1); FirstDayOfTheMonth = new DateTime(Today.Year, Today.Month, 1); LastDayOfTheMonth = FirstDayOfTheMonth.AddMonths(1).AddDays(-1); }
public IEnumerable <ScheduleTileDayData> GetDataForAllDays() { DateTime[] dates = new DateTime[DaysIncludingToday]; for (int i = 0; i < dates.Length; i++) { dates[i] = Today.AddDays(i); } return(dates.Select(i => CreateDayData(i))); }
public sealed override DateTimeRange CalculateFromInput(string input = "") { DateTime start = Today.AddDays(value: -(int)Today.DayOfWeek + 1); return(new DateTimeRange { Start = start, End = start.AddDays(6) }); }
public sealed override DateTimeRange CalculateFromInput(string input = "") { DateTime yesterday = Today.AddDays(value: -1); return(new DateTimeRange { Start = yesterday, End = yesterday }); }
public UserSettingsController(IUnitOfWork _unitOfWork, IImagePath imagePath, UserManager <ApplicationUser> userManager, IHostingEnvironment env) : base(_unitOfWork) { _imagePath = imagePath; _userManager = userManager; _env = env; Now = BaseHelper.UserGeo().UserDateTime; Today = Now.Date; Tommorow = Today.AddDays(1); FirstDayOfTheMonth = new DateTime(Today.Year, Today.Month, 1); LastDayOfTheMonth = FirstDayOfTheMonth.AddMonths(1).AddDays(-1); }
static DateHelper() { Tomorrow = Today.AddDays(1); Yesterday = Today.AddDays(-1); NextBusinessDay = Tomorrow; while (NextBusinessDay.DayOfWeek == DayOfWeek.Saturday || NextBusinessDay.DayOfWeek == DayOfWeek.Sunday) { NextBusinessDay = NextBusinessDay.AddDays(1); } }
public sealed override DateTimeRange CalculateFromInput(string input = "") { DateTime nextMonthSameDay = Today.AddMonths(months: 1); DateTime end = Today.AddMonths(months: 1).AddDays(value: -nextMonthSameDay.Day); return(new DateTimeRange { Start = Today.AddDays(value: -Today.Day + 1), End = end }); }
private void ClearUI() { imgDiscountCodeError.Visible = false; txtDiscountCode.Text = string.Empty; txtDiscountPercentage.Text = string.Empty; txtDuration.Text = "1"; lblweek.InnerText = " week"; dtExpireDate.MinDate = Today; dtExpireDate.SelectedDate = Today.AddDays(txtDuration.Value.Value * 7); txtInstanceCount.Text = "1"; imgDurationError.Visible = false; imgExpireDate.Visible = false; }
public TripTimeConverter(Trip trip, DateTime?today, DateTime?now) { if (!today.HasValue) { today = DateTime.Today; } if (!now.HasValue) { now = DateTime.Now; } SourceTrip = trip; Now = now.Value; Today = today.Value; Yesterday = Today.AddDays(-1); }
private void WeekForm_Load(object sender, EventArgs e) { Today = DateTime.Today; var x = Today.ToPersianDateString().Split('/'); var xx = Today.ToPersianDateString().AddDaysToShamsiDate(13).Split('/'); YearStart = x[0].Substring(2); MonthStart = x[1]; DayStart = x[2]; YearEnd = xx[0].Substring(2); MonthEnd = xx[1]; DayEnd = xx[2]; cmbYearStart.Items.Add(YearStart); cmbYearEnd.Items.Add(YearStart); if (YearStart != YearEnd) { cmbYearStart.Items.Add(YearEnd); cmbYearEnd.Items.Add(YearEnd); } cmbYearStart.Text = YearStart; cmbYearEnd.Text = YearEnd; cmbMonthStart.Items.Add(MonthStart); cmbMonthEnd.Items.Add(MonthStart); if (MonthStart != MonthEnd) { cmbMonthStart.Items.Add(MonthEnd); cmbMonthEnd.Items.Add(MonthEnd); } cmbMonthStart.Text = MonthStart; cmbMonthEnd.Text = MonthEnd; var list = Today.ToPersianDateString().ReturnDaysOfMonth(); cmbDayStart.DataSource = list; var listt = Today.AddDays(30).ToPersianDateString().ReturnDaysOfMonth(); cmbDayEnd.DataSource = listt; cmbDayStart.Text = DayStart; cmbDayEnd.Text = DayEnd; }
/// <summary> /// Setting the grid to display current week /// </summary> protected void SetGrid() { //converting times based on US Mountain standard time, as it does not get the correct time when deployed to azure var currentTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time"); Today = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, currentTimeZone); BeginOfWeekDateTime = Today.AddDays(-(int)Today.DayOfWeek).Date; EndOfWeekDateTime = Today.AddDays(6 - (int)Today.DayOfWeek).Date; BeginOfWeek = BeginOfWeekDateTime.ToString("M"); EndOfWeek = EndOfWeekDateTime.ToString("M"); Day1Week = BeginOfWeekDateTime.Date; Day2Week = BeginOfWeekDateTime.AddDays(1); Day3Week = BeginOfWeekDateTime.AddDays(2); Day4Week = BeginOfWeekDateTime.AddDays(3); Day5Week = BeginOfWeekDateTime.AddDays(4); Day6Week = BeginOfWeekDateTime.AddDays(5); Day7Week = BeginOfWeekDateTime.AddDays(6); }
public void Should_fail_when_asserting_nullable_numeric_value_equals_a_different_value() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- DateTime?nullableDateTimeA = Today; DateTime?nullableDateTimeB = Today.AddDays(2); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action action = () => nullableDateTimeA.Should().Be(nullableDateTimeB); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- action.ShouldThrow <AssertFailedException>(); }
public void Should_support_chaining_constraints_with_and() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- DateTime yesterday = Today.AddDays(-1); DateTime?nullableDateTime = Today; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action action = () => nullableDateTime.Should() .HaveValue() .And .BeAfter(yesterday); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- action.ShouldNotThrow(); }
private void DayDateIdent(string dayString, TokenKind tokenKind) { DateTime pivotDate; if (tokenKind == TokenKind.NEXT) { pivotDate = Today.AddDays(1); } else { pivotDate = Today; } for (var i = 0; i < 7; i++) { if (pivotDate.AddDays(i).DayOfWeek == (DayOfWeek)Enum.Parse(typeof(DayOfWeek), dayString, true)) { _dateRange.AddDate(pivotDate.AddDays(i)); return; } } Errors.Add($"Unable to parse day '{dayString}'"); }
public void Setup() { Today = DateTime.Today; Tomorrow = Today.AddDays(1); Yesterday = Today.AddDays(-1); }
public void InitializeTest() { Today = DateTime.Today; Yesterday = Today.AddDays(-1); Tomorrow = Today.AddDays(1); }
private DateTime Ago(int days) { return(Today.AddDays(-days)); }
protected void btnOk_Click(object sender, EventArgs e) { if (txtDiscountCode.Text.Trim().Length == 0) { spanErrorMsg.InnerText = "Discount Code cannot be empty."; spanErrorMsg.Visible = true; return; } //Validate the Discount Code. DiscountCode discountCode = GetBL <FinanceBL>().GetDiscountCode(txtDiscountCode.Text.Trim()); if (discountCode == null) { //Invalid Discount Code. spanErrorMsg.InnerText = "Invalid Discount Code."; spanErrorMsg.Visible = true; return; } if (discountCode.ExpireDate.Date < Today) { //If it is expired spanErrorMsg.InnerText = "Discount Code has expired."; spanErrorMsg.Visible = true; return; } //If the usage limit has exceeded. var dicountCodeUsageList = GetBL <FinanceBL>().GetDiscountCodeUsages(discountCode.DiscountCodeID, true); if (dicountCodeUsageList.Count() == discountCode.InstanceCount) { spanErrorMsg.InnerText = "This Discount code has reached its maximum instance count."; spanErrorMsg.Visible = true; return; } //if the new discount code is already being used if (dicountCodeUsageList.Where(dcu => dcu.CompanyId == CompanyId).FirstOrDefault() != null) { spanErrorMsg.InnerText = "Discount Code has already been used by this company."; spanErrorMsg.Visible = true; return; } spanErrorMsg.Visible = false; DiscountCodeUsage newDiscountCodeUsage = new DiscountCodeUsage(); newDiscountCodeUsage.DiscountCodeId = discountCode.DiscountCodeID; newDiscountCodeUsage.CreatedDate = newDiscountCodeUsage.LastUpdatedDate = Now; newDiscountCodeUsage.StartDate = Today; newDiscountCodeUsage.EndDate = Today.AddDays(discountCode.Duration * 7); newDiscountCodeUsage.CreatedByUserId = newDiscountCodeUsage.LastUpdatedByUserId = UserID; newDiscountCodeUsage.CompanyId = CompanyId; newDiscountCodeUsage.IsAdminApplied = true; newDiscountCodeUsage.IsActive = true; GetBL <FinanceBL>().AddDiscountCodeUsageBySBAdmin(newDiscountCodeUsage, UserID); popupManageDiscount.HidePopup(); LoadDiscountCodes(); }
public List <RawDailySalesItem> GetDailyHistory(DateTime?When) { List <RawDailySalesItem> Results = new List <RawDailySalesItem>(); DateTime Today; if (When.HasValue) { Today = When.Value.Date; } else { Today = DateTime.Now.Date.AddDays(-1); } DateTime Tomorrow = Today.AddDays(1); InitializeConnection(); // need to resolve any merchant sequence number issues // now get the details var DailyHistories = from h in GiftEntity.Histories where h.WhenHappened > Today && h.WhenHappened < Tomorrow && h.ErrorCode == "APP " && h.TransType != "DYRP" && // keep the daily report out of this h.TransType != "SHIP" // keep the card shipments out of the report orderby h.ID //c.Card2 == WhichCard.ID select new { ID = h.ID, CardGUID = h.CardGUID, TransType = h.TransType, When = h.WhenHappened, Amount = h.Amount, PointsGranted = 0, MerchWhere = h.WhichMerchantGUID, Clrk = h.Clerk, Text = h.TransactionText, CardGUID2 = h.CardGUID2, CouponUsed = "", CouponIssued = "", PrizeAwardedGUID = "", InvoiceNumber = h.InvoiceNumber }; foreach (var his in DailyHistories) { RawDailySalesItem nHistory = new RawDailySalesItem(); nHistory.ID = his.ID; nHistory.CardNumber = (from c in GiftEntity.Cards where c.CardGUID == his.CardGUID select c.CardNumLast4).FirstOrDefault(); nHistory.Amount = his.Amount; Merchant tMerchant = (from m in GiftEntity.Merchants where m.MerchantGUID == his.MerchWhere select m).FirstOrDefault(); if (tMerchant != null) { nHistory.MerchantID = tMerchant.MerchantID; } nHistory.TransType = his.TransType; nHistory.WhenHappened = his.When; Results.Add(nHistory); } return(Results); }
private void OnDoCommence(object sender, CommenceArgs e) { Today = StartDate; if (DoInitialSummary != null) { DoInitialSummary.Invoke(this, args); } if (StartOfSimulation != null) { StartOfSimulation.Invoke(this, args); } if (CLEMInitialiseResource != null) { CLEMInitialiseResource.Invoke(this, args); } if (CLEMInitialiseActivity != null) { CLEMInitialiseActivity.Invoke(this, args); } if (FinalInitialise != null) { FinalInitialise.Invoke(this, args); } if (CLEMValidate != null) { CLEMValidate.Invoke(this, args); } while (Today <= EndDate && (e.CancelToken == null || !e.CancelToken.IsCancellationRequested)) { if (DoWeather != null) { DoWeather.Invoke(this, args); } if (DoDailyInitialisation != null) { DoDailyInitialisation.Invoke(this, args); } if (StartOfDay != null) { StartOfDay.Invoke(this, args); } if (Today.Day == 1 && StartOfMonth != null) { StartOfMonth.Invoke(this, args); } if (Today.DayOfYear == 1 && StartOfYear != null) { StartOfYear.Invoke(this, args); } if (Today.DayOfWeek == DayOfWeek.Sunday && StartOfWeek != null) { StartOfWeek.Invoke(this, args); } if (DoManagement != null) { DoManagement.Invoke(this, args); } if (DoPestDiseaseDamage != null) { DoPestDiseaseDamage.Invoke(this, args); } if (DoEnergyArbitration != null) { DoEnergyArbitration.Invoke(this, args); } if (DoSoilWaterMovement != null) { DoSoilWaterMovement.Invoke(this, args); } if (DoSoilTemperature != null) { DoSoilTemperature.Invoke(this, args); } if (DoSoilOrganicMatter != null) { DoSoilOrganicMatter.Invoke(this, args); } if (DoSurfaceOrganicMatterDecomposition != null) { DoSurfaceOrganicMatterDecomposition.Invoke(this, args); } if (DoUpdateWaterDemand != null) { DoUpdateWaterDemand.Invoke(this, args); } if (DoWaterArbitration != null) { DoWaterArbitration.Invoke(this, args); } if (PrePhenology != null) { PrePhenology.Invoke(this, args); } if (DoPhenology != null) { DoPhenology.Invoke(this, args); } if (DoPotentialPlantGrowth != null) { DoPotentialPlantGrowth.Invoke(this, args); } if (DoPotentialPlantPartioning != null) { DoPotentialPlantPartioning.Invoke(this, args); } if (DoNutrientArbitration != null) { DoNutrientArbitration.Invoke(this, args); } if (DoActualPlantPartioning != null) { DoActualPlantPartioning.Invoke(this, args); } if (DoActualPlantGrowth != null) { DoActualPlantGrowth.Invoke(this, args); } if (DoStock != null) { DoStock.Invoke(this, args); } if (DoLifecycle != null) { DoLifecycle.Invoke(this, args); } if (DoUpdate != null) { DoUpdate.Invoke(this, args); } if (DoManagementCalculations != null) { DoManagementCalculations.Invoke(this, args); } if (DoReportCalculations != null) { DoReportCalculations.Invoke(this, args); } if (Today.DayOfWeek == DayOfWeek.Saturday && EndOfWeek != null) { EndOfWeek.Invoke(this, args); } if (Today.Day == 31 && Today.Month == 12 && EndOfYear != null) { EndOfYear.Invoke(this, args); } if (Today.AddDays(1).Day == 1 && EndOfMonth != null) // is tomorrow the start of a new month? { // CLEM events performed before APSIM EndOfMonth if (CLEMStartOfTimeStep != null) { CLEMStartOfTimeStep.Invoke(this, args); } if (CLEMUpdateLabourAvailability != null) { CLEMUpdateLabourAvailability.Invoke(this, args); } if (CLEMUpdatePasture != null) { CLEMUpdatePasture.Invoke(this, args); } if (CLEMPastureReady != null) { CLEMPastureReady.Invoke(this, args); } if (CLEMDoCutAndCarry != null) { CLEMDoCutAndCarry.Invoke(this, args); } if (CLEMAnimalBreeding != null) { CLEMAnimalBreeding.Invoke(this, args); } if (CLEMAnimalMilkProduction != null) { CLEMAnimalMilkProduction.Invoke(this, args); } if (CLEMPotentialIntake != null) { CLEMPotentialIntake.Invoke(this, args); } if (CLEMGetResourcesRequired != null) { CLEMGetResourcesRequired.Invoke(this, args); } if (CLEMAnimalWeightGain != null) { CLEMAnimalWeightGain.Invoke(this, args); } if (CLEMCalculateManure != null) { CLEMCalculateManure.Invoke(this, args); } if (CLEMCollectManure != null) { CLEMCollectManure.Invoke(this, args); } if (CLEMAnimalDeath != null) { CLEMAnimalDeath.Invoke(this, args); } if (CLEMAnimalMilking != null) { CLEMAnimalMilking.Invoke(this, args); } if (CLEMCalculateEcologicalState != null) { CLEMCalculateEcologicalState.Invoke(this, args); } if (CLEMAnimalManage != null) { CLEMAnimalManage.Invoke(this, args); } if (CLEMAnimalStock != null) { CLEMAnimalStock.Invoke(this, args); } if (CLEMAnimalSell != null) { CLEMAnimalSell.Invoke(this, args); } if (CLEMDetachPasture != null) { CLEMDetachPasture.Invoke(this, args); } if (CLEMHerdSummary != null) { CLEMHerdSummary.Invoke(this, args); } if (CLEMAgeResources != null) { CLEMAgeResources.Invoke(this, args); } if (CLEMAnimalBuy != null) { CLEMAnimalBuy.Invoke(this, args); } if (CLEMEndOfTimeStep != null) { CLEMEndOfTimeStep.Invoke(this, args); } EndOfMonth.Invoke(this, args); } if (EndOfDay != null) { EndOfDay.Invoke(this, args); } if (DoReport != null) { DoReport.Invoke(this, args); } Today = Today.AddDays(1); } Today = EndDate; if (EndOfSimulation != null) { EndOfSimulation.Invoke(this, args); } Summary?.WriteMessage(this, "Simulation terminated normally"); }
private void DateExpression() { switch (Peek(1).Kind) { case TokenKind.TODAY: _dateRange.AddDate(Today); Load(); break; case TokenKind.TOMORROW: _dateRange.AddDate(Today.AddDays(1)); Load(); break; case TokenKind.YESTERDAY: _dateRange.AddDate(Today.AddDays(-1)); Load(); break; case TokenKind.DAY_IDENTIFIER: DayDateIdent(Peek(1).Text, TokenKind.DAY); Load(); break; case TokenKind.NUMBER: var num = int.Parse(Peek(1).Text); Load(); switch (Peek(1).Kind) { case TokenKind.DAY: case TokenKind.WEEK: case TokenKind.MONTH: case TokenKind.YEAR: NumQuickDateIdent(num); break; case TokenKind.MONTH_MODIFIER: Load(); MonthDateIdent(num); break; } break; case TokenKind.NEXT: Load(); NumQuickDateIdent(1); break; case TokenKind.PREVIOUS: Load(); NumQuickDateIdent(-1); break; } //Get Or Time Year switch (Peek(1).Kind) { case TokenKind.NUMBER: Year(); Load(); if (Peek(1).Kind == TokenKind.AT) { Time(); } break; case TokenKind.AT: Time(); break; } Load(); }