Ejemplo n.º 1
0
        public SmokeTest()
        {
            var tim = new LocalDateTime(2020, 5, 4, 14, 43, 0);  //NowDateTime, 04-05-2020 2:43 PM

            _zoneGmt = DateTimeZoneProviders.Tzdb["Europe/London"];
            _clock   = new FakeClock(tim.InZoneStrictly(_zoneGmt).ToInstant());

            _isolationNoSymptoms = tim.InZoneStrictly(_zoneGmt).ToInstant().Plus(Duration.FromDays(isolationDaysNoSymptoms));
            _isolationSymptoms   = tim.InZoneStrictly(_zoneGmt).ToInstant().Plus(Duration.FromDays(isolationDaysSymptoms));
        }
Ejemplo n.º 2
0
        public IndexFormProcTest()
        {
            _zoneGmt = DateTimeZoneProviders.Tzdb["Europe/London"];
            var tim = new LocalDateTime(StdLocalTimeYear, StdLocalTimeMonth, StdLocalTimeDay, StdLocalTimeHour, StdLocalTimeMins, StdLocalTimeSec);

            _clock = new FakeClock(tim.InZoneStrictly(_zoneGmt).ToInstant());
        }
Ejemplo n.º 3
0
        public async Task TestFrequencyWeekly()
        {
            var symbol    = "AAPL";
            var timeZone  = "America/New_York".ToTimeZone();
            var startDate = new LocalDateTime(2019, 1, 10, 16, 0);
            var instant   = startDate.InZoneStrictly(timeZone).ToInstant();

            var ticks = await new YahooHistory()
                        .FromDate(instant)
                        .Frequency(Frequency.Weekly)
                        .GetPricesAsync(symbol);

            if (ticks == null)
            {
                throw new Exception($"Invalid symbol: {symbol}");
            }

            var instant1 = new LocalDateTime(2019, 1, 7, 16, 0).InZoneStrictly(timeZone).ToInstant();

            Assert.Equal(instant1, ticks[0].Date); // previous Monday
            var instant2 = new LocalDateTime(2019, 1, 14, 16, 0).InZoneStrictly(timeZone).ToInstant();

            Assert.Equal(instant2, ticks[1].Date);
            Assert.Equal(150.850006m, ticks[1].Open);
        }
Ejemplo n.º 4
0
        public void ZonedDateTime_ToString()
        {
            var           local = new LocalDateTime(2013, 7, 23, 13, 05, 20);
            ZonedDateTime zoned = local.InZoneStrictly(SampleZone);

            Assert.AreEqual("2013-07-23T13:05:20 Single (+04)", zoned.ToString());
        }
Ejemplo n.º 5
0
        public async Task TestFrequencyMonthly()
        {
            var symbol    = "AAPL";
            var timeZone  = "America/New_York".ToTimeZone();
            var startDate = new LocalDateTime(2019, 1, 10, 16, 0);
            var instant   = startDate.InZoneStrictly(timeZone).ToInstant();

            var ticks = await YahooHistory
                        .FromDate(instant)
                        .Frequency(Frequency.Monthly)
                        .GetPricesAsync(symbol);

            if (ticks == null)
            {
                throw new Exception($"Invalid symbol: {symbol}");
            }

            foreach (var tick in ticks)
            {
                Write($"{tick.Date} {tick.Close}");
            }

            var instant1 = new LocalDateTime(2019, 2, 1, 16, 0).InZoneStrictly(timeZone).ToInstant();

            Assert.Equal(instant1, ticks[0].Date); // next start of month!
            var instant2 = new LocalDateTime(2019, 3, 1, 16, 0).InZoneStrictly(timeZone).ToInstant();

            Assert.Equal(instant2, ticks[1].Date);
            Assert.Equal(174.279999m, ticks[1].Open);
        }
Ejemplo n.º 6
0
        public void ZonedDateTime_ToString_WithFormat()
        {
            var           local = new LocalDateTime(2013, 7, 23, 13, 05, 20);
            ZonedDateTime zoned = local.InZoneStrictly(SampleZone);

            Assert.AreEqual("2013/07/23 13:05:20 Single", zoned.ToString("yyyy/MM/dd HH:mm:ss z", CultureInfo.InvariantCulture));
        }
Ejemplo n.º 7
0
 public void JulianEpoch()
 {
     // Compute the Julian epoch using the Julian calendar, instead of the
     // Gregorian version.
     var localEpoch = new LocalDateTime(-4712, 1, 1, 12, 0, CalendarSystem.Julian);
     var epoch = localEpoch.InZoneStrictly(DateTimeZone.Utc).ToInstant();
     Assert.AreEqual(epoch, NodaConstants.JulianEpoch);
 }
Ejemplo n.º 8
0
        public static string ToStringWithOffset(this LocalDateTime localDateTime)
        {
            var zonedDateTime = localDateTime.InZoneStrictly(Zone.Value);

            return(zonedDateTime.ToString(
                       "yyyy-MM-ddTHH:mm:sso<g>",
                       CultureInfo.InvariantCulture));
        }
Ejemplo n.º 9
0
        public void InZoneStrictly_InSummer()
        {
            var local = new LocalDateTime(2009, 6, 22, 21, 39, 30);
            var zoned = local.InZoneStrictly(Pacific);

            Assert.AreEqual(local, zoned.LocalDateTime);
            Assert.AreEqual(Offset.FromHours(-7), zoned.Offset);
        }
Ejemplo n.º 10
0
        public void JulianEpoch()
        {
            // Compute the Julian epoch using the Julian calendar, instead of the
            // Gregorian version.
            var localEpoch = new LocalDateTime(-4712, 1, 1, 12, 0, CalendarSystem.Julian);
            var epoch      = localEpoch.InZoneStrictly(DateTimeZone.Utc).ToInstant();

            Assert.AreEqual(epoch, NodaConstants.JulianEpoch);
        }
Ejemplo n.º 11
0
        public void ToDateTimeOffset_OffsetEdgeOfRange(int hours)
        {
            var ldt    = new LocalDateTime(2017, 1, 9, 21, 45, 20);
            var offset = Offset.FromHours(hours);
            var zone   = DateTimeZone.ForOffset(offset);
            var zdt    = ldt.InZoneStrictly(zone);

            Assert.AreEqual(hours, zdt.ToDateTimeOffset().Offset.TotalHours);
        }
Ejemplo n.º 12
0
        public void Construct_FromLocal_ValidUnambiguousOffset()
        {
            SingleTransitionDateTimeZone zone = new SingleTransitionDateTimeZone(Instant.FromUtc(2011, 6, 12, 22, 0), 4, 3);

            LocalDateTime local = new LocalDateTime(2000, 1, 2, 3, 4, 5);
            ZonedDateTime zoned = new ZonedDateTime(local, zone, zone.EarlyInterval.WallOffset);

            Assert.AreEqual(zoned, local.InZoneStrictly(zone));
        }
        public async Task ScheduleGuildEvent(
            CommandContext context,
            [Description("The channel to announce the event in")]
            DiscordChannel announcementChannel,
            [Description("The role to announce the event to")]
            DiscordRole role,
            [Description("The date to schedule the event for")]
            [RemainingText]
            string datetimeString
            )
        {
            using IBotAccessProvider provider = this.accessBuilder.Build();

            if (!context.User.TryGetDateTimeZone(provider, this.timeZoneProvider, out DateTimeZone schedulerTimeZone))
            {
                await context.RespondAsync(StringConstants.NoTimeZoneErrorMessage);

                return;
            }

            DiscordMember botMember = await context.Guild.GetMemberAsync(context.Client.CurrentUser.Id);

            if (!announcementChannel.PermissionsFor(botMember).HasPermission(Permissions.SendMessages | Permissions.MentionEveryone))
            {
                await context.RespondAsync($"{context.Member.Mention}, I don't have permission to send messages and mention `@everyone` in that channel.");

                return;
            }

            LocalDateTime datetime = Recognizers.RecognizeDateTime(datetimeString, DateTimeV2Type.DateTime)
                                     .First().Values.Select(value => (LocalDateTime)value.Value).OrderBy(key => key).First();
            DiscordMessage msg = await context.RespondAsync($":wave: Hi, {context.User.Mention}! You want to schedule an event for {datetime:g} in your timezone?");

            InteractivityExtension interactivity = context.Client.GetInteractivity();
            Reaction reaction = await interactivity.AddAndWaitForYesNoReaction(msg, context.User);

            if (reaction != Reaction.Yes)
            {
                return;
            }

            DiscordEmbedBuilder scheduleEmbedBase = new DiscordEmbedBuilder()
                                                    .WithTitle("Select an event by typing: <event number>")
                                                    .WithColor(context.Member.Color);

            GuildEvent selectedEvent = await SelectPredefinedEvent(context, provider, msg, interactivity, scheduleEmbedBase);

            Instant      eventDateTime = datetime.InZoneStrictly(schedulerTimeZone).ToInstant();
            DiscordEmbed embed         = new DiscordEmbedBuilder()
                                         .WithAuthor(context.Member.DisplayName, iconUrl: context.Member.AvatarUrl)
                                         .WithDescription(selectedEvent.EventDesc)
                                         .WithTitle(selectedEvent.EventName)
                                         .Build();
            await msg.ModifyAsync($"You have scheduled the following event for {datetime:g} in your time zone to be output in the {announcementChannel.Mention} channel.", embed : embed);

            this.ScheduleEventsForRole(context, announcementChannel, provider, selectedEvent, eventDateTime, role);
        }
Ejemplo n.º 14
0
        public MxCultureInfoTest()
        {
            _zoneGmt = DateTimeZoneProviders.Tzdb[id : "Europe/London"];

            _startIsolation = new LocalDateTime(year: 2020, month: 03, day: 29, hour: 00, minute: 59, second: 59).InZoneStrictly(zone: _zoneGmt).ToInstant();
            _clockTime      = new LocalDateTime(year: 2020, month: 01, day: 30, hour: 17, minute: 45, second: 59);

            _clock = new FakeClock(initial: _clockTime.InZoneStrictly(zone: _zoneGmt).ToInstant());
        }
Ejemplo n.º 15
0
        public void ToDateTimeOffset_OffsetOutOfRange(int hours)
        {
            var ldt    = new LocalDateTime(2017, 1, 9, 21, 45, 20);
            var offset = Offset.FromHours(hours);
            var zone   = DateTimeZone.ForOffset(offset);
            var zdt    = ldt.InZoneStrictly(zone);

            Assert.Throws <InvalidOperationException>(() => zdt.ToDateTimeOffset());
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Calculate the non-working time between the specified dates and times of day.
        /// </summary>
        /// <param name="from">Starting date and time of day</param>
        /// <param name="to">Ending date and time of day</param>
        /// <returns>Duration of non-working time</returns>
        public Duration CalculateNonWorkingTime(LocalDateTime from, LocalDateTime to)
        {
            Duration sum = Duration.Zero;

            Instant fromInstant = from.InZoneStrictly(ZONE_ID).ToInstant();
            long    fromSeconds = fromInstant.ToUnixTimeSeconds();

            Instant toInstant = to.InZoneStrictly(ZONE_ID).ToInstant();
            long    toSeconds = toInstant.ToUnixTimeSeconds();

            foreach (NonWorkingPeriod period in NonWorkingPeriods)
            {
                LocalDateTime start = period.StartDateTime;

                Instant startInstant = start.InZoneStrictly(ZONE_ID).ToInstant();
                long    startSeconds = startInstant.ToUnixTimeSeconds();

                LocalDateTime end        = period.GetEndDateTime();
                Instant       endInstant = end.InZoneStrictly(ZONE_ID).ToInstant();
                long          endSeconds = endInstant.ToUnixTimeSeconds();

                if (fromSeconds >= endSeconds)
                {
                    // look at next period
                    continue;
                }

                if (toSeconds <= startSeconds)
                {
                    // done with periods
                    break;
                }

                if (fromSeconds <= endSeconds)
                {
                    // found a period, check edge conditions
                    if (fromSeconds > startSeconds)
                    {
                        startSeconds = fromSeconds;
                    }

                    if (toSeconds < endSeconds)
                    {
                        endSeconds = toSeconds;
                    }

                    sum = sum.Plus(Duration.FromSeconds(endSeconds - startSeconds));
                }

                if (toSeconds <= endSeconds)
                {
                    break;
                }
            }
            return(sum);
        }
Ejemplo n.º 17
0
 public RoyalePublisherGame ToDomain(RoyaleYearQuarter yearQuarter, MasterGameYear masterGameYear)
 {
     if (Timestamp.Kind != DateTimeKind.Utc)
     {
         LocalDateTime localDateTime = LocalDateTime.FromDateTime(Timestamp);
         Instant       instant       = localDateTime.InZoneStrictly(TimeExtensions.EasternTimeZone).ToInstant();
         return(new RoyalePublisherGame(PublisherID, yearQuarter, masterGameYear, instant, AmountSpent, AdvertisingMoney, FantasyPoints));
     }
     return(new RoyalePublisherGame(PublisherID, yearQuarter, masterGameYear, Instant.FromDateTimeUtc(Timestamp), AmountSpent, AdvertisingMoney, FantasyPoints));
 }
 public RoyalePublisherGame ToDomain(RoyaleYearQuarter yearQuarter, MasterGameYear masterGameYear)
 {
     if (Timestamp.Kind != DateTimeKind.Utc)
     {
         LocalDateTime localDateTime = LocalDateTime.FromDateTime(Timestamp);
         Instant       instant       = localDateTime.InZoneStrictly(DateTimeZoneProviders.Tzdb.GetZoneOrNull("America/New_York")).ToInstant();
         return(new RoyalePublisherGame(PublisherID, yearQuarter, masterGameYear, instant, AmountSpent, AdvertisingMoney, FantasyPoints));
     }
     return(new RoyalePublisherGame(PublisherID, yearQuarter, masterGameYear, Instant.FromDateTimeUtc(Timestamp), AmountSpent, AdvertisingMoney, FantasyPoints));
 }
Ejemplo n.º 19
0
 public AppliedZoneResult(LocalDateTime local, DateTimeZone dateTimeZone)
 {
     try {
         AsLocal1 = local.InZoneStrictly(dateTimeZone).ToInstant();
     } catch (AmbiguousTimeException ambiguousTimeException) {
         AsLocal1 = ambiguousTimeException.EarlierMapping.ToInstant();
         AsLocal2 = ambiguousTimeException.LaterMapping.ToInstant();
     } catch (SkippedTimeException) {
         // intentionally blank
     }
 }
    public static string ToStringWithOffset(this LocalDateTime localDateTime)
    {
        if (localDateTime == null)
        {
            return("");
        }
        var zonedDateTime = localDateTime.InZoneStrictly(Zone.Value);

        return(zonedDateTime.ToString(
                   "yyyy-MM-ddTHH:mm:sso<g>",
                   System.Globalization.CultureInfo.InvariantCulture));
    }
Ejemplo n.º 21
0
        public void ToDateTimeOffset_TruncatedOffset(int hours, int minutes, int seconds)
        {
            var ldt    = new LocalDateTime(2017, 1, 9, 21, 45, 20);
            var offset = Offset.FromHoursAndMinutes(hours, minutes).Plus(Offset.FromSeconds(seconds));
            var zone   = DateTimeZone.ForOffset(offset);
            var zdt    = ldt.InZoneStrictly(zone);
            var dto    = zdt.ToDateTimeOffset();

            // We preserve the local date/time, so the instant will move forward as the offset
            // is truncated.
            Assert.AreEqual(new DateTime(2017, 1, 9, 21, 45, 20, DateTimeKind.Unspecified), dto.DateTime);
            Assert.AreEqual(TimeSpan.FromHours(hours) + TimeSpan.FromMinutes(minutes), dto.Offset);
        }
        private static ZonedDateTime GetZonedDateTime(int year, int month, int day, int hour, int minute, int second, string timeZoneId, bool inZoneLeniantly)
        {
            var localDateTime = new LocalDateTime(year, month, day, hour, minute, second);

            if (inZoneLeniantly)
            {
                return(localDateTime.InZoneLeniently(DateTimeZoneProviders.Tzdb[timeZoneId]));
            }

            else
            {
                return(localDateTime.InZoneStrictly(DateTimeZoneProviders.Tzdb[timeZoneId]));
            }
        }
Ejemplo n.º 23
0
        public void Can_Query_By_Equals_Using_A_UtcTime_OffsetDateTime_Stored_As_DateTimeOffset()
        {
            var           timeZoneUnitedKingdom    = DateTimeZoneProviders.Tzdb.GetZoneOrNull("Europe/London");
            LocalDateTime localTimeInUnitedKingom  = new LocalDateTime(2016, 06, 01, 10, 40);
            ZonedDateTime zonedStartDateTime       = localTimeInUnitedKingom.InZoneStrictly(timeZoneUnitedKingdom);
            ZonedDateTime zonedFinishDateTime      = zonedStartDateTime.Plus(Duration.FromMinutes(60));
            ZonedDateTime matchingUtcZonedDateTime = zonedStartDateTime.WithZone(DateTimeZone.Utc);

            var offsetStartTime    = new OffsetDateTime(zonedStartDateTime.LocalDateTime, zonedStartDateTime.Offset);
            var offsetFinishTime   = new OffsetDateTime(zonedFinishDateTime.LocalDateTime, zonedFinishDateTime.Offset);
            var offsetStartTimeUtc = matchingUtcZonedDateTime.ToOffsetDateTime();

            var testEvent = new OffsetDateTimeTestEntity
            {
                Description          = "Can_Query_By_Equals_Using_A_UtcTime_OffsetDateTime_Stored_As_DateTimeOffset",
                SystemDateTimeOffset = DateTimeOffset.Now,
                StartOffsetDateTime  = offsetStartTime,
                FinishOffsetDateTime = offsetFinishTime
            };

            using (ISession session = SessionFactory.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(testEvent);
                    transaction.Commit();
                }

            // Even though two OffsetDateTimes may refer to the same instant...
            Assert.That(offsetStartTime.ToInstant(), Is.EqualTo(offsetStartTimeUtc.ToInstant()));
            // They are not considered equal by NodaTime unless the LocalDateTime and Offset parts are both equal.
            // (There is nothing wrong with this, it is perfectly valid logic for comparing two OffsetDateTimes.)
            Assert.That(offsetStartTime, Is.Not.EqualTo(offsetStartTimeUtc));

            // However we are storing OffsetDateTimes as DateTimeOffsets in the sql server.
            // So when using Linq and sending the expression to the sql server,
            // the sql server will convert all DateTimeOffsets to utc time before comparing them.
            // Therefore the same two OffsetDateTimes that are not equal as shown above are seen as being equal by sql.
            using (ISession session = SessionFactory.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    var query          = session.Query <OffsetDateTimeTestEntity>().Where(x => x.StartOffsetDateTime == offsetStartTimeUtc);
                    var retrievedEvent = query.SingleOrDefault();
                    transaction.Commit();
                    Assert.That(testEvent, Is.Not.Null);
                    Assert.That(testEvent, Is.EqualTo(retrievedEvent));
                }
        }
Ejemplo n.º 24
0
        private Instant GetNextBidTime()
        {
            var       currentTime = _clock.GetCurrentInstant();
            var       nyc         = TimeExtensions.EasternTimeZone;
            LocalDate currentDate = currentTime.InZone(nyc).LocalDateTime.Date;
            LocalDate nextBidDate;

            if (currentDate.DayOfWeek == IsoDayOfWeek.Monday)
            {
                nextBidDate = currentDate;
            }
            else
            {
                nextBidDate = currentDate.Next(IsoDayOfWeek.Monday);
            }

            LocalDateTime dateTime = nextBidDate + new LocalTime(20, 0);

            return(dateTime.InZoneStrictly(nyc).ToInstant());
        }
Ejemplo n.º 25
0
    public static Instant GetPreviousBidTime(this IClock clock)
    {
        var       currentTime     = clock.GetCurrentInstant();
        var       nyc             = EasternTimeZone;
        var       currentDateTime = currentTime.InZone(nyc).LocalDateTime;
        LocalDate previousBidDate;

        if (currentDateTime.Date.DayOfWeek == ActionProcessingDay && currentDateTime.TimeOfDay > ActionProcessingTime)
        {
            previousBidDate = currentDateTime.Date;
        }
        else
        {
            previousBidDate = currentDateTime.Date.Previous(ActionProcessingDay);
        }

        LocalDateTime dateTime = previousBidDate + ActionProcessingTime;

        return(dateTime.InZoneStrictly(nyc).ToInstant());
    }
Ejemplo n.º 26
0
        public async Task TestFrequencyDaily()
        {
            var symbol    = "AAPL";
            var timeZone  = "America/New_York".ToTimeZone();
            var startDate = new LocalDateTime(2019, 1, 10, 16, 0);
            var instant   = startDate.InZoneStrictly(timeZone).ToInstant();

            var ticks1 = await YahooHistory
                         .FromDate(instant)
                         .Frequency(Frequency.Daily)
                         .GetPricesAsync(symbol);

            if (ticks1 == null)
            {
                throw new Exception($"Invalid symbol: {symbol}");
            }

            Assert.Equal(instant, ticks1[0].Date);
            Assert.Equal(instant.Plus(Duration.FromDays(1)), ticks1[1].Date);
            Assert.Equal(152.880005m, ticks1[1].Open);
        }
Ejemplo n.º 27
0
    private static Instant GetNextTime(this IClock clock, IsoDayOfWeek dayOfWeek, LocalTime timeOnDay)
    {
        var       currentTime      = clock.GetCurrentInstant();
        var       nyc              = EasternTimeZone;
        var       localDateTime    = currentTime.InZone(nyc).LocalDateTime;
        LocalDate currentDate      = localDateTime.Date;
        LocalTime currentLocalTime = localDateTime.TimeOfDay;
        LocalDate nextPublicRevealDate;

        if (currentDate.DayOfWeek == dayOfWeek)
        {
            nextPublicRevealDate = currentLocalTime >= timeOnDay?currentDate.Next(dayOfWeek) : currentDate;
        }
        else
        {
            nextPublicRevealDate = currentDate.Next(dayOfWeek);
        }

        LocalDateTime dateTime = nextPublicRevealDate + timeOnDay;

        return(dateTime.InZoneStrictly(nyc).ToInstant());
    }
Ejemplo n.º 28
0
        public static void Main(string[] args)
        {
            var birthTimeZone = DateTimeZoneProviders.Tzdb["Europe/London"];
            var birthDateTime = new LocalDateTime(1992, 04, 04, 00, 12, 00);
            var birthInstant  = birthDateTime.InZoneStrictly(birthTimeZone).ToInstant();

            var clock = SystemClock.Instance;

            do
            {
                var now = clock.GetCurrentInstant();

                var duration = Instant.Subtract(now, birthInstant);

                Console.WriteLine($"{duration.Days:N0} days, {duration.Hours:N0} hours, {duration.Minutes:N0} minutes, {duration.Seconds:N0} seconds");
                Console.WriteLine();
                Console.WriteLine($"{duration.TotalDays:N0} total days");
                Console.WriteLine($"{duration.TotalHours:N0} total hours");
                Console.WriteLine($"{duration.TotalMinutes:N0} total minutes");
                Console.WriteLine($"{duration.TotalSeconds:N0} total seconds");
                Console.WriteLine($"{duration.TotalMilliseconds:N0} total milliseconds");
            } while (string.IsNullOrEmpty(Console.ReadLine()));
        }
Ejemplo n.º 29
0
 public void InZoneStrictly_ThrowsWhenAmbiguous()
 {
     var local = new LocalDateTime(2009, 11, 1, 1, 30, 0);
     Assert.Throws<AmbiguousTimeException>(() => local.InZoneStrictly(Pacific));
 }
Ejemplo n.º 30
0
        public void InZoneStrictly_ThrowsWhenSkipped()
        {
            var local = new LocalDateTime(2009, 3, 8, 2, 30, 0);

            Assert.Throws <SkippedTimeException>(() => local.InZoneStrictly(Pacific));
        }
Ejemplo n.º 31
0
        public void InZoneStrictly_ThrowsWhenAmbiguous()
        {
            var local = new LocalDateTime(2009, 11, 1, 1, 30, 0);

            Assert.Throws <AmbiguousTimeException>(() => local.InZoneStrictly(Pacific));
        }
Ejemplo n.º 32
0
 public void ZonedDateTime_ToString_WithFormat()
 {
     var local = new LocalDateTime(2013, 7, 23, 13, 05, 20);
     ZonedDateTime zoned = local.InZoneStrictly(SampleZone);
     Assert.AreEqual("2013/07/23 13:05:20 Single", zoned.ToString("yyyy/MM/dd HH:mm:ss z", CultureInfo.InvariantCulture));
 }
Ejemplo n.º 33
0
 public void ZonedDateTime_ToString()
 {
     var local = new LocalDateTime(2013, 7, 23, 13, 05, 20);
     ZonedDateTime zoned = local.InZoneStrictly(SampleZone);
     Assert.AreEqual("2013-07-23T13:05:20 Single (+04)", zoned.ToString());
 }
Ejemplo n.º 34
0
        public void Construct_FromLocal_ValidUnambiguousOffset()
        {
            SingleTransitionDateTimeZone zone = new SingleTransitionDateTimeZone(Instant.FromUtc(2011, 6, 12, 22, 0), 4, 3);

            LocalDateTime local = new LocalDateTime(2000, 1, 2, 3, 4, 5);
            ZonedDateTime zoned = new ZonedDateTime(local, zone, zone.EarlyInterval.WallOffset);
            Assert.AreEqual(zoned, local.InZoneStrictly(zone));
        }
 public void ConvertLocalToUtc()
 {
     SummerLocal.InZoneStrictly(Pacific);
 }
Ejemplo n.º 36
0
 public void InZoneStrictly_InSummer()
 {
     var local = new LocalDateTime(2009, 6, 22, 21, 39, 30);
     var zoned = local.InZoneStrictly(Pacific);
     Assert.AreEqual(local, zoned.LocalDateTime);
     Assert.AreEqual(Offset.FromHours(-7), zoned.Offset);
 }
Ejemplo n.º 37
0
 public void InZoneStrictly_ThrowsWhenSkipped()
 {
     var local = new LocalDateTime(2009, 3, 8, 2, 30, 0);
     Assert.Throws<SkippedTimeException>(() => local.InZoneStrictly(Pacific));
 }