Esempio n. 1
0
        public async Task <IDictionary <string, object> > Handle(IDictionary <string, object> status, ControllerContext context, CancellationToken cancellationToken = default)
        {
            status["now"]                  = myClock.GetCurrentZonedDateTime().ToDateTimeOffset();
            status["defaultTimeZone"]      = $"{myClock.Zone.Id}, {myClock.Zone.GetZoneInterval(myClock.GetCurrentInstant())}";
            status["assetsRoot"]           = myUrlHelper.AssetsContent("~");
            status["lastAppliedMigration"] = (await myDB.Database.GetAppliedMigrationsAsync(cancellationToken)).LastOrDefault();
            status["polls"]                = await myDB.Set <Poll>().LongCountAsync(cancellationToken);

            status["IGNs"] = await myDB.Set <Player>().Where(_ => _.Nickname != null).LongCountAsync(cancellationToken);

            status["FCs"] = await myDB.Set <Player>().Where(_ => _.FriendCode != null).LongCountAsync(cancellationToken);

            return(status);
        }
Esempio n. 2
0
        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());
        }
        public static Duration TimeUntilTomorrow(this ZonedClock clock)
        {
            ZonedDateTime zonedNow = clock.GetCurrentZonedDateTime();
            LocalDate     date     = zonedNow.Date;
            LocalTime     time     = zonedNow.TimeOfDay;
            LocalTime     threeAM  = new LocalTime(03, 00);

            if (time > threeAM)
            {
                date = date.PlusDays(1);
            }
            LocalDateTime next3AM      = date + threeAM;
            ZonedDateTime zonedNext3AM = zonedNow.Zone.AtLeniently(next3AM);

            return(zonedNext3AM - zonedNow);
        }
Esempio n. 4
0
 public static ZonedDateTime GetCurrentSydneyTime() => Clock.GetCurrentZonedDateTime();