public async Task <IActionResult> SetDateTime( string id, [FromBody] CurrentDateTime datetime, [FromQuery] string?taskId, [FromQuery] int asyncTimeout = PrintJob.DefaultTimeout) { if (!context.IsReady) { return(StatusCode(StatusCodes.Status405MethodNotAllowed)); } if (context.Printers.TryGetValue(id, out IFiscalPrinter? printer)) { var result = await context.RunAsync( new PrintJob { Printer = printer, Action = PrintJobAction.SetDateTime, Document = datetime, AsyncTimeout = asyncTimeout, TaskId = taskId }); return(Ok(result)); } return(NotFound()); }
//For form class static TestDevice() { DateTime CurrentDateTime; CurrentDateTime = DateTime.Now; Console.WriteLine("Today is: {0}", CurrentDateTime.ToLongTimeString()); }
public CalendarViewModel() { var startDateTime = DateTime.Today.AddDays(-DateTime.Today.Day + 1); CurrentDateTime = startDateTime; Back = new Command(() => { try { CurrentDateTime = CurrentDateTime.AddMonths(-1); } catch (Exception) // possible ArgumentOutOfRangeException { CurrentDateTime = DateTime.MinValue; } }); Next = new Command(() => { try { CurrentDateTime = CurrentDateTime.AddMonths(1); } catch (Exception) // possible ArgumentOutOfRangeException { CurrentDateTime = DateTime.MaxValue; } }); Func <bool> canSelectRange = () => FromTime <= UntilTime; SelectRange = new Command(() => DidSelectRangeClicked?.Invoke(this, EventArgs.Empty), canSelectRange); }
private void Form2_Load(object sender, EventArgs e) { CurrentDateTime.Start(); userBalance.Text = ""; userBalance.Text = _account.Balance.ToString(); }
public bool Step() { if (CurrentDateTime >= EndDateTime) { return(false); } ++CurrentStep; var nextStepDateTime = CurrentDateTime.AddHours(_hoursPerStep); if (nextStepDateTime > EndDateTime) { nextStepDateTime = EndDateTime; } var maxLimitDayTime = nextStepDateTime.AddHours(-_maxHoursUntilRequest); while (CurrentDateTime < maxLimitDayTime) { var hoursPassed = _rand.Next(1, _maxHoursUntilRequest); CurrentDateTime = CurrentDateTime.AddHours(Convert.ToDouble(hoursPassed)); GenerateRequest(); } CurrentDateTime = nextStepDateTime; GenerateRequest(); return(true); }
public void Init() { bool isSunrise = false; bool isSunset = false; DateTime sunrise = DateTime.Now; DateTime sunset = DateTime.Now; int ltD = (int)LocationData.Latitude; //DateTime = DateTime.AddDays(10); SunTimes.Instance.CalculateSunRiseSetTimes(new SunTimes.LatitudeCoords ((int)LocationData.Latitude, (int)((LocationData.Latitude - (int)LocationData.Latitude) * 60), 0, SunTimes.LatitudeCoords.Direction.North), new SunTimes.LongitudeCoords ((int)LocationData.Longitude, (int)((LocationData.Longitude - (int)LocationData.Longitude) * 60), 0, SunTimes.LongitudeCoords.Direction.East), CurrentDateTime, LocationData.TimeZone, ref sunrise, ref sunset, ref isSunrise, ref isSunset); if (CurrentDateTime > sunset) { DateTime sunrise2 = DateTime.Now; DateTime sunset2 = DateTime.Now; SunTimes.Instance.CalculateSunRiseSetTimes(new SunTimes.LatitudeCoords ((int)LocationData.Latitude, (int)((LocationData.Latitude - (int)LocationData.Latitude) * 60), 0, SunTimes.LatitudeCoords.Direction.North), new SunTimes.LongitudeCoords ((int)LocationData.Longitude, (int)((LocationData.Longitude - (int)LocationData.Longitude) * 60), 0, SunTimes.LongitudeCoords.Direction.East), CurrentDateTime.AddDays(1), LocationData.TimeZone, ref sunrise2, ref sunset2, ref isSunrise, ref isSunset); sunrise = sunset; sunset = sunrise2; } SunRise = LocationData.GetStandardTime(sunrise); SunSet = LocationData.GetStandardTime(sunset); Muthurtha = new AstroMuhurtha(LocationData.OriginalDateTime, SunRise, SunSet); }
private void TimelineBand_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { //鼠标水平移动距离 double moveX = e.GetPosition(null).X - _dragPoint.X; long timeScaleUnitTicks = TimelineHelper.GetScaleUnitTicks(TimeScaleUnit); long moveTicks = -(long)(moveX / TimeScaleUnitWidth * timeScaleUnitTicks); DateTime moveTempDateTime = CurrentDateTime.AddTicks(moveTicks); DateTime moveTargetDateTime = moveTempDateTime; if (moveTempDateTime < MinDateTime) { moveTargetDateTime = MinDateTime; } else if (moveTempDateTime > MaxDateTime) { moveTargetDateTime = MaxDateTime; } //设置当前时间点 CurrentDateTime = moveTargetDateTime; if (IsMainBand && _hostTimeline != null) { _hostTimeline.CurrentDateTime = CurrentDateTime; } _dragPoint = e.GetPosition(null); } }
public override ICollection <EntryStatsView> GetPopularEntries(int blogId, DateFilter filter) { DateTime?minDate = null; if (filter == DateFilter.LastMonth) { minDate = CurrentDateTime.AddMonths(-1); } else if (filter == DateFilter.LastWeek) { minDate = CurrentDateTime.AddDays(-7); } else if (filter == DateFilter.LastYear) { minDate = CurrentDateTime.AddYears(-1); } using (IDataReader reader = _procedures.GetPopularPosts(BlogId, minDate)) { return(reader.ReadCollection(r => { var entry = r.ReadEntryStatsView(); entry.PostType = PostType.BlogPost; return entry; })); } }
public bool IsContageous(Person person) { if (person.IsInfected()) { return(CurrentDateTime.Subtract(person.DateInfected.Value).TotalHours >= HoursFromInfectionToContegeousness); } return(false); }
public void Uses_the_current_date_as_the_ticket_issue_date() { CurrentDateTime.SetNow(new DateTime(2010, 12, 25, 1, 2, 3)); var result = CreateTheTicket(); result.IssueDate.ShouldEqual(new DateTime(2010, 12, 25, 1, 2, 3)); }
private void SetHrStringListValues() { _dateTimeList.Clear(); for (int i = 0; i < _viewWindowMaxHrs + 1; i++) { _dateTimeList.Add(CurrentDateTime.AddHours(-(_viewWindowMiddle - (1 * i)))); } }
public void GetEvent() { GetService.GetEvent(CurrentDateTime.FirstDayOfMonth().ToEpoch(), CurrentDateTime.EndOfLastDayOfMonth().ToEpoch(), (objSucces) => { SortEvent(objSucces); AddTag(objSucces); }, (obj) => { }); }
public override void SetUp() { _currentDateTime = new CurrentDateTime(new DateTime(DateTime.Now.Year, 11, 01)); _mockApprenticeshipCoreValidator.Setup(m => m.MapOverlappingErrors(It.IsAny <GetOverlappingApprenticeshipsQueryResponse>())) .Returns(new Dictionary <string, string>()); base.SetUp(); }
public bool GetNextAscendantBefore(GregorianDateTime stopDateTime) { if (stopDateTime.GetJulianComplete() < CurrentDateTime.GetJulianComplete()) { return(false); } GetNextAscendent(); return(stopDateTime.GetJulianComplete() > CurrentDateTime.GetJulianComplete()); }
public static void CheckOut(ref Reservation r, CurrentDateTime current) { if (DateTime.Compare(current.time, r.checkIn) > 0) { r.checkOut = current.time; r.Room.occupied = false; //Delete reservation after checkout. r.Room.Reservations.Remove(r); } }
//當前服務器日期及時間 public static CurrentDateTime GetCurrentDateList() { string strSql = "Select CONVERT(varchar(20),getdate(),23) AS curr_date,CONVERT(varchar(20),getdate(),120) AS curr_datetime"; DataTable dt = SQLHelper.ExecuteSqlReturnDataTable(strSql); CurrentDateTime objModel = new CurrentDateTime(); objModel.current_date = dt.Rows[0]["curr_date"].ToString(); objModel.current_datetime = dt.Rows[0]["curr_datetime"].ToString(); return(objModel); }
protected override void apply(Type pluginType, IConfiguredInstance instance) { var constructorParameter = instance?.Constructor?.GetParameters().FirstOrDefault(x => x.ParameterType == typeof(ICurrentDateTime)); if (constructorParameter != null) { var param = new CurrentDateTime(GetCurrentTimeFromConfiguration()); instance.Dependencies.AddForConstructorParameter(constructorParameter, param); } }
public void Adds_the_number_of_minutes_from_the_principal_provider_to_the_current_date_to_get_the_expiration_date() { testPrincipalProvider.TicketDataToReturn.NumberOfMinutesUntilExpiration = 31; CurrentDateTime.SetNow(new DateTime(2010, 12, 25, 1, 2, 3)); var expectedExpirationDate = new DateTime(2010, 12, 25, 1, 2, 3).AddMinutes(31); var result = CreateTheTicket(); result.Expiration.ShouldEqual(expectedExpirationDate); }
public ActionResult <PrintResult> SetDateTime(string id, [FromBody] CurrentDateTime currentDateTime) { if (context.Printers.TryGetValue(id, out IFiscalPrinter printer)) { return(new PrintResult { Status = printer.SetDateTime(currentDateTime.DateTime) }); } return(NotFound()); }
public void ShouldPassValidationForPlanedEndDateInFuture(int monthsToAdd, int currentDay) { CurrentDateTime.Setup(x => x.Now).Returns(new DateTime(2019, 3, currentDay)); var endDate = new DateTimeViewModel(CurrentDateTime.Object.Now.AddMonths(monthsToAdd)) { Day = 1 }; var result = Validator.CheckEndDateInFuture(endDate); result.HasValue.Should().BeFalse(); }
public ActionResult CheckInConfirmed(int id) { CurrentDateTime curr = new CurrentDateTime(); curr.time = System.DateTime.Now; Reservation reservation = db.Reservations.Find(id); int customerId = (int)Session["customer"]; Customer customer = db.Customers.Find(customerId); var checkedIn = CustomerOperations.CheckIn(ref customer, ref reservation, curr.time); if(checkedIn) db.SaveChanges(); //TODO: else return RedirectToAction("Index"); }
//overload function for guest public static bool CheckIn(ref Reservation r, CurrentDateTime current) { bool checkin = true; if (DateTime.Compare(current.time, r.checkIn) < 0 || DateTime.Compare(current.time, r.checkOut) > 0) { checkin = false; return(checkin); } r.Room.occupied = true; return(checkin); }
private void UpdatePresentTime() { CurrentDateTime = DateTime.Now; PresentTimeSpanString = GetTimeSpan(); PresentTimeString = CurrentDateTime.ToString("HH:mm"); string Month = MonthToEnglish(CurrentDateTime.Month); string DayOfMonth = CurrentDateTime.Day.ToString(); string DayOfWeek = WeekdayToEnglish(CurrentDateTime.DayOfWeek); PresentDateString = $"{DayOfWeek} - {Month} {DayOfMonth}"; }
public static ICollection <Reservation> ViewReservation(Customer customer, CurrentDateTime current) { ICollection <Reservation> view = new List <Reservation>(); foreach (Reservation r in customer.Reservations) { if (DateTime.Compare(r.checkIn, current.time) > 0) { view.Add(r); } } return(view); }
public Vehicle_Overview() { memberStateCertificate = new MemberStateCertificate(); vuCertificate = new VuCertificate(); vehicleIdentificationNumber = new VehicleIdentificationNumber(); vehicleRegistrationIdentification = new VehicleRegistrationIdentification(); currentDateTime = new CurrentDateTime(); vuDownloadablePeriod = new VuDownloadablePeriod(); cardSlotsStatus = new CardSlotsStatus(); vuDownloadActivityData = new VuDownloadActivityData(); vuCompanyLocksData = new VuCompanyLocksData(); vuControlActivityData = new VuControlActivityData(); }
public void ShouldFailValidationForPlanedEndDateNotInFuture(int monthsToAdd, int currentDay) { CurrentDateTime.Setup(x => x.Now).Returns(new DateTime(2019, 3, currentDay)); var endDate = new DateTimeViewModel(CurrentDateTime.Object.Now.AddMonths(monthsToAdd)) { Day = 1 }; var result = Validator.CheckEndDateInFuture(endDate); result.HasValue.Should().BeTrue(); result.Value.Key.Should().Be("EndDate"); result.Value.Value.Should().Be("The end date must not be in the past"); }
public static bool CancelReservation(Reservation r, CurrentDateTime current) { bool err = true; if (DateTime.Compare(current.time, r.checkIn) < 0) { r.Room.Reservations.Remove(r); r.People.Reservations.Remove(r); } else { err = false; } return(err); }
private void DynamicUpdate() { CurrentDateTime = DateTime.Now; CurrentTime = CurrentDateTime.ToShortTimeString(); float hour = CurrentDateTime.Hour; hour = hour > 12 ? (hour % 12) : hour; float min = CurrentDateTime.Minute; float sec = CurrentDateTime.Second; Minutes = min / 5f + (sec / 60f * 0.2f); Hour = hour + (min / 60f); Seconds = (sec / 5f); }
/// <summary> /// to upload file /// </summary> /// <param name="file">posted file base</param> /// <param name="fileTuye">fileType like Image, video, document</param> /// <returns>saved file name</returns> public static string UploadFile(HttpPostedFileBase file) { string fileName = ""; try { fileName = CurrentDateTime.ToString("ddMMyyhhmmss") + "." + file.FileName.Split('.')[1]; string path = ApplicationPath() + "DataContainer\\Documents\\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } file.SaveAs(path + fileName); } catch { } return(fileName); }
public TimeService(IScheduler scheduler) { this.scheduler = scheduler; previousSecondLocalDateTime = CurrentDateTime.ToLocalTime(); midnightSubject = new Subject <DateTimeOffset>(); CurrentDateTimeObservable = Observable .Interval(TimeSpan.FromSeconds(1), scheduler) .Select(_ => CurrentDateTime) .Do(tickOnMidnight) .Publish(); MidnightObservable = midnightSubject.AsObservable().Publish(); disposable.Add(CurrentDateTimeObservable.Connect()); disposable.Add(MidnightObservable.Connect()); }