public void CreateWithCurrentCulture()
 {
     using (CultureSaver.SetCultures(Cultures.DotTimeSeparator))
     {
         var pattern = ZonedDateTimePattern.CreateWithCurrentCulture("HH:mm", null);
         var text    = pattern.Format(Instant.FromUtc(2000, 1, 1, 19, 30).InUtc());
         Assert.AreEqual("19.30", text);
     }
 }
Пример #2
0
        public void ZonedDateTimeConvertsCorrectlyToDateTimeOffset()
        {
            var zdt =
                ZonedDateTimePattern.CreateWithCurrentCulture("G", DateTimeZoneProviders.Tzdb)
                .Parse("2020-07-02T11:00:00 UTC-05 (-05)");

            Assert.True(zdt.Success);
            var date = _mapper.Map <DateTimeOffset>(zdt.Value);

            Assert.Equal(zdt.Value, ZonedDateTime.FromDateTimeOffset(date));
        }
Пример #3
0
 public static string ForDisplay(this ZonedDateTime zonedDateTime) =>
 $"{ZonedDateTimePattern.CreateWithCurrentCulture("HH:mm:ss", DateTimeZoneProviders.Tzdb).Format(zonedDateTime)} on " +
 $"{ZonedDateTimePattern.CreateWithCurrentCulture("dd MMM", DateTimeZoneProviders.Tzdb).Format(zonedDateTime)}";