public void InZone_WithCalendar() { var clock = new FakeClock(NodaConstants.UnixEpoch); var zoned = clock.InZone(NewYork, CalendarSystem.Julian); var zonedEpoch = NodaConstants.UnixEpoch.InZone(NewYork, CalendarSystem.Julian); Assert.AreEqual(zonedEpoch, zoned.GetCurrentZonedDateTime()); }
public void Properties() { var calendar = CalendarSystem.Julian; var clock = new FakeClock(NodaConstants.UnixEpoch); var zonedClock = clock.InZone(SampleZone, calendar); Assert.AreSame(clock, zonedClock.Clock); Assert.AreSame(calendar, zonedClock.Calendar); Assert.AreSame(SampleZone, zonedClock.Zone); }
public void GetCurrent() { var julian = CalendarSystem.Julian; FakeClock underlyingClock = new FakeClock(NodaConstants.UnixEpoch); ZonedClock zonedClock = underlyingClock.InZone(SampleZone, julian); Assert.AreEqual(NodaConstants.UnixEpoch, zonedClock.GetCurrentInstant()); Assert.AreEqual(new ZonedDateTime(underlyingClock.GetCurrentInstant(), SampleZone, julian), zonedClock.GetCurrentZonedDateTime()); Assert.AreEqual(new LocalDateTime(1969, 12, 19, 2, 0, julian), zonedClock.GetCurrentLocalDateTime()); Assert.AreEqual(new LocalDateTime(1969, 12, 19, 2, 0, julian).WithOffset(Offset.FromHours(2)), zonedClock.GetCurrentOffsetDateTime()); Assert.AreEqual(new LocalDate(1969, 12, 19, julian), zonedClock.GetCurrentDate()); Assert.AreEqual(new LocalTime(2, 0, 0), zonedClock.GetCurrentTimeOfDay()); }