/// <summary> /// The default constructor. /// Defaults to 0 deg lat, 0 deg lng, 0 m elevation, metric units, January 1, Year 1 CE (AD), ID of 0 /// </summary> public Location() { Latitude = 0; Longitude = 0; Elevation = 0; Unit = 'm'; Date = new LocalDate(1, 1, 1); ID = 0; }
/// <summary> /// Takes Lat, lng and elevation, metric units, January 1, Year 1 CE (AD), ID of 0 /// </summary> /// <param name="Lat"></param> /// <param name="Long"></param> /// <param name="Elevate"></param> public Location(double Lat, double Long, double Elevate) { Debug.Assert(Lat <= 90); Debug.Assert(Lat >= -90); Debug.Assert(Long <= 180); Debug.Assert(Long >= -180); Latitude = Lat; Longitude = Long; Elevation = Elevate; Date = new LocalDate(1, 1, 1); Unit = 'm';; ID = 0; }
public void If_candidate_has_resigned_temporarily_with_resume_date__then_aggregate_has_HasResignedTemporarily_flag_and_HasResignedEffectively_with_date_after_resuma_date_returns_true() { // Arrange var id = EnrollmentAggregate.EnrollmentId.New; var event1 = new DomainEvent <EnrollmentAggregate, EnrollmentAggregate.EnrollmentId, RecruitmentFormSubmitted>( new RecruitmentFormSubmitted( NodaTime.SystemClock.Instance.GetCurrentInstant(), "Andrzej", "Strzelba", EmailAddress.Parse("*****@*****.**"), Consts.FakePhoneNumber, "ala ma kota", 1, "Wolne Miasto Gdańsk", new[] { "Wadowice" }, new[] { 1 }, true), new Metadata(), DateTimeOffset.Now, id, 1 ); var enrollment = new EnrollmentAggregate(id); enrollment.ApplyEvents(new IDomainEvent[] { event1 }); var recordingCoordinator = new ApplicationUser() { Id = Guid.NewGuid() }; var currentDate = new NodaTime.LocalDate(2020, 06, 30); // Act var result = enrollment.RecordResignation(new RecordResignation.Command() { EnrollmentId = id.GetGuid(), CommunicationChannel = CommunicationChannel.OutgoingEmail, ResignationReason = "brak powodu", AdditionalNotes = "notatka testowa", ResignationType = RecordResignation.ResignationType.Temporary, ResumeDate = currentDate.PlusWeeks(1) }, recordingCoordinator, currentDate.AtStartOfDayInZone(Consts.MainTimezone).ToInstant()); // Assert Assert.True(result.IsSuccess); var uncommittedEvent = Assert.Single(enrollment.UncommittedEvents, e => e.AggregateEvent is CandidateResignedTemporarily); var @event = Assert.IsType <CandidateResignedTemporarily>(uncommittedEvent.AggregateEvent); Assert.Equal(recordingCoordinator.Id, @event.RecordingCoordinatorID); Assert.Equal(CommunicationChannel.OutgoingEmail, @event.CommunicationChannel); Assert.Equal("brak powodu", @event.ResignationReason); Assert.Equal("notatka testowa", @event.AdditionalNotes); Assert.Equal(currentDate.PlusWeeks(1), @event.ResumeDate); enrollment.HasResignedEffectively(currentDate.PlusWeeks(2).AtStartOfDayInZone(Consts.MainTimezone).ToInstant()).Should().BeFalse(); }
public void ResumeDate_cannot_be_earlier_than_today() { // Arrange var id = EnrollmentAggregate.EnrollmentId.New; var event1 = new DomainEvent <EnrollmentAggregate, EnrollmentAggregate.EnrollmentId, RecruitmentFormSubmitted>( new RecruitmentFormSubmitted( NodaTime.SystemClock.Instance.GetCurrentInstant(), "Andrzej", "Strzelba", EmailAddress.Parse("*****@*****.**"), Consts.FakePhoneNumber, "ala ma kota", 1, "Wolne Miasto Gdańsk", new[] { "Wadowice" }, new[] { 1 }, true), new Metadata(), DateTimeOffset.Now, id, 1 ); var enrollment = new EnrollmentAggregate(id); enrollment.ApplyEvents(new IDomainEvent[] { event1 }); var recordingCoordinator = new ApplicationUser() { Id = Guid.NewGuid() }; var currentDate = new NodaTime.LocalDate(2020, 06, 30); // Act var result = enrollment.RecordResignation(new RecordResignation.Command() { EnrollmentId = id.GetGuid(), CommunicationChannel = CommunicationChannel.IncomingEmail, ResignationReason = "brak powodu", AdditionalNotes = "notatka testowa", ResignationType = RecordResignation.ResignationType.Temporary, ResumeDate = currentDate.Minus(Period.FromDays(1)) }, recordingCoordinator, currentDate.AtStartOfDayInZone(Consts.MainTimezone).ToInstant()); // Assert Assert.False(result.IsSuccess); var error = Assert.IsType <Error.DomainError>(result.Error); error.Message.Should().BeEquivalentTo(RecordResignation_Messages.ResumeDateCannotBeEarlierThanToday); }
public Location(int degLat, int minLat, int secLat, String CardinalLat, int degLng, int minLng, int secLng, String CardinalLng, double E) { Debug.Assert(degLat >= 0); Debug.Assert(degLat <= 90); Debug.Assert(minLat >= 0); Debug.Assert(minLat <= 59); Debug.Assert(secLat >= 0); Debug.Assert(degLng >= 0); Debug.Assert(degLng <= 180); Debug.Assert(minLng >= 0); Debug.Assert(minLng <= 59); Debug.Assert(secLng >= 0); Debug.Assert(CardinalLat.ToUpper() == "N" || CardinalLat.ToUpper() == "S"); Debug.Assert(CardinalLng.ToUpper() == "W" || CardinalLng.ToUpper() == "E"); SetLatitude(degLat, minLat, secLat, CardinalLat); SetLongitude(degLng, minLng, secLng, CardinalLng); SetElevation(E); Date = new LocalDate(1, 1, 1); Unit = 'm'; }
/// <summary> /// To LocalDateTime /// </summary> /// <param name="ld"></param> /// <param name="hours"></param> /// <param name="calendar"></param> /// <returns></returns> public static LocalDateTime ToLocalDateTime(this LocalDate ld, int hours, CalendarSystem calendar) => new LocalDateTime(ld.Year, ld.Month, ld.Day, hours, 0, calendar);
/// <summary> /// To LocalDateTime /// </summary> /// <param name="ld"></param> /// <param name="hours"></param> /// <returns></returns> public static LocalDateTime ToLocalDateTime(this LocalDate ld, int hours) => new LocalDateTime(ld.Year, ld.Month, ld.Day, hours, 0);
/// <summary> /// Returns the next date with the specified day-of-week, or the original date, if the day is already correct.<br/> /// 返回具有指定星期几的下一个日期,或者返回原始日期(如果该日期已经正确)。 /// </summary> /// <param name="ld"></param> /// <param name="dayOfWeek"></param> /// <returns></returns> public static LocalDate NextOrSame(this LocalDate ld, IsoDayOfWeek dayOfWeek) { return(DateAdjusters.NextOrSame(dayOfWeek)(ld)); }
public OffsetDateTime WithCalendar([NotNull] CalendarSystem calendar) { LocalDate newDate = Date.WithCalendar(calendar); return(new OffsetDateTime(newDate.YearMonthDayCalendar, nanosecondsAndOffset)); }
/// <summary> /// To LocalDateTime /// </summary> /// <param name="ld"></param> /// <param name="hours"></param> /// <param name="minutes"></param> /// <param name="seconds"></param> /// <param name="milliseconds"></param> /// <param name="calendar"></param> /// <returns></returns> public static LocalDateTime ToLocalDateTime(this LocalDate ld, int hours, int minutes, int seconds, int milliseconds, CalendarSystem calendar) => new LocalDateTime(ld.Year, ld.Month, ld.Day, hours, minutes, seconds, milliseconds, calendar);
/// <summary> /// Get the day that the month starts. <br /> /// 获得一个月开始的那一天。 /// </summary> /// <param name="ld"></param> /// <returns></returns> public static LocalDate BeginningOfMonth(this LocalDate ld) => DateAdjusters.StartOfMonth(ld);
/// <summary> /// Set the month.<br /> /// 设置月份。 /// </summary> /// <param name="ld"></param> /// <param name="month"></param> /// <returns></returns> public static LocalDate SetMonth(this LocalDate ld, int month) => DateAdjusters.Month(month)(ld);
/// <summary> /// Set the day.<br /> /// 设置日期中的天。 /// </summary> /// <param name="ld"></param> /// <param name="day"></param> /// <returns></returns> public static LocalDate SetDay(this LocalDate ld, int day) => DateAdjusters.DayOfMonth(day)(ld);
/// <summary> /// Set the year, month, and day.<br /> /// 设置年、月和日。 /// </summary> /// <param name="ld"></param> /// <param name="year"></param> /// <param name="month"></param> /// <param name="day"></param> /// <returns></returns> public static LocalDate SetDate(this LocalDate ld, int year, int month, int day) => new LocalDate(ld.Era, year, month, day, ld.Calendar);
/// <summary> /// Set the year.<br /> /// 设置年份。 /// </summary> /// <param name="ld"></param> /// <param name="year"></param> /// <returns></returns> public static LocalDate SetYear(this LocalDate ld, int year) => new LocalDate(ld.Era, year, ld.Month, ld.Day, ld.Calendar);
/// <summary> /// Returns the previous date with the specified day-of-week, or the original date, if the day is already correct.<br/> /// 返回具有指定星期几的上一个日期,或者返回原始日期(如果该日期已经正确)。 /// </summary> /// <param name="ld"></param> /// <param name="dayOfWeek"></param> /// <returns></returns> public static LocalDate PreviousOrSame(this LocalDate ld, IsoDayOfWeek dayOfWeek) { return(DateAdjusters.PreviousOrSame(dayOfWeek)(ld)); }
/// <summary> /// Add months.<br /> /// 添加月数。 /// </summary> /// <param name="ld"></param> /// <param name="months"></param> /// <returns></returns> public static LocalDate AddMonths(this LocalDate ld, int months) => ld.PlusMonths(months);
/// <summary> /// Returns the previous date with the specified day-of-week.<br/> /// 返回具有指定星期几的上一个日期。 /// </summary> /// <param name="ld"></param> /// <param name="dayOfWeek"></param> /// <returns></returns> public static LocalDate Previous(this LocalDate ld, DayOfWeek dayOfWeek) { return(DateAdjusters.Previous(dayOfWeek.AsIsoDayOfWeek())(ld)); }
/// <summary> /// Add years.<br /> /// 添加年数。 /// </summary> /// <param name="ld"></param> /// <param name="years"></param> /// <returns></returns> public static LocalDate AddYears(this LocalDate ld, int years) => ld.PlusYears(years);
/// <summary> /// Add quarters.<br /> /// 添加季数。 /// </summary> /// <param name="ld"></param> /// <param name="quarters"></param> /// <returns></returns> public static LocalDate AddQuarters(this LocalDate ld, int quarters) => ld.PlusMonths(quarters * 3);
/// <summary> /// To LocalDateTime /// </summary> /// <param name="ld"></param> /// <param name="hours"></param> /// <param name="minutes"></param> /// <param name="seconds"></param> /// <returns></returns> public static LocalDateTime ToLocalDateTime(this LocalDate ld, int hours, int minutes, int seconds) => new LocalDateTime(ld.Year, ld.Month, ld.Day, hours, minutes, seconds);
/// <summary> /// To DateTime /// </summary> /// <param name="ld"></param> /// <returns></returns> public static DateTime ToDateTime(this LocalDate ld) => ld.ToDateTimeUnspecified();
/// <summary> /// Add period. <br /> /// 添加一段时间。 /// </summary> /// <param name="ts"></param> /// <param name="period"></param> /// <returns></returns> public static LocalDate Add(this LocalDate ts, Period period) => ts.Plus(period);
/// <summary> /// Previous Day.<br /> /// 上一天。 /// </summary> /// <param name="ld"></param> /// <returns></returns> public static LocalDate PreviousDay(this LocalDate ld) => ld.AddDays(-1);
/// <summary> /// Gets first day of year. <br /> /// 获取一年的第一天。 /// </summary> /// <param name="ld"></param> /// <returns></returns> public static LocalDate FirstDayOfYear(this LocalDate ld) => ld.SetDate(ld.Year, 1, 1);
/// <summary> /// To DateInfo /// </summary> /// <param name="ld"></param> /// <returns></returns> public static DateInfo ToDateInfo(this LocalDate ld) => new DateInfo(ld.Year, ld.Month, ld.Day);
public OffsetDateTime With([NotNull] Func <LocalDate, LocalDate> adjuster) { LocalDate newDate = Date.With(adjuster); return(new OffsetDateTime(newDate.YearMonthDayCalendar, nanosecondsAndOffset)); }
/// <summary> /// To LocalDateTime /// </summary> /// <param name="ld"></param> /// <returns></returns> public static LocalDateTime ToLocalDateTime(this LocalDate ld) => new LocalDateTime(ld.Year, ld.Month, ld.Day, 0, 0);
/// <summary> /// To Datetime /// </summary> /// <param name="ld"></param> /// <param name="kind"></param> /// <returns></returns> public static DateTime ToDateTime(this LocalDate ld, DateTimeKind kind) => DateTimeFactory.Create(ld.Year, ld.Month, ld.Day, 0, 0, 0, 0, kind);
/// <summary> /// Returns the next date with the specified day-of-week. <br/> /// 返回具有指定星期几的下一个日期。 /// </summary> /// <param name="ld"></param> /// <param name="dayOfWeek"></param> /// <returns></returns> public static LocalDate Next(this LocalDate ld, DayOfWeek dayOfWeek) { return(DateAdjusters.Next(dayOfWeek.AsIsoDayOfWeek())(ld)); }