Esempio n. 1
0
 public void ZoneIntervalToString()
 {
     using (CultureSaver.SetCultures(CultureInfo.InvariantCulture))
     {
         Assert.AreEqual("TestTime: [2011-06-03T10:15:00Z, 2011-08-02T13:45:00Z) +09 (+01)", SampleInterval.ToString());
     }
 }
 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);
     }
 }
 public void TestGetInstance_CultureInfo()
 {
     NodaFormatInfo.ClearCache();
     using (CultureSaver.SetCultures(enUs, FailingCultureInfo.Instance))
     {
         var actual = NodaFormatInfo.GetInstance(enGb);
         Assert.AreSame(enGb, actual.CultureInfo);
     }
 }
Esempio n. 4
0
 public void CreateWithCurrentCulture()
 {
     using (CultureSaver.SetCultures(Cultures.DotTimeSeparator))
     {
         var pattern = InstantPattern.CreateWithCurrentCulture("HH:mm:ss");
         var text    = pattern.Format(Instant.FromUtc(2000, 1, 1, 12, 34, 56));
         Assert.AreEqual("12.34.56", text);
     }
 }
 public void CreateWithCurrentCulture()
 {
     using (CultureSaver.SetCultures(Cultures.DotTimeSeparator))
     {
         var pattern = LocalTimePattern.CreateWithCurrentCulture("HH:mm");
         var text    = pattern.Format(new LocalTime(13, 45));
         Assert.AreEqual("13.45", text);
     }
 }
Esempio n. 6
0
 public void CreateWithCurrentCulture()
 {
     using (CultureSaver.SetCultures(Cultures.DotTimeSeparator))
     {
         var pattern = OffsetPattern.CreateWithCurrentCulture("H:mm");
         var text    = pattern.Format(Offset.FromHoursAndMinutes(1, 30));
         Assert.AreEqual("1.30", text);
     }
 }
 public void TestGetInstance_IFormatProvider()
 {
     NodaFormatInfo.ClearCache();
     using (CultureSaver.SetCultures(enUs, FailingCultureInfo.Instance))
     {
         var provider = new EmptyFormatProvider();
         var actual   = NodaFormatInfo.GetInstance(provider);
         Assert.AreSame(enUs, actual.CultureInfo);
     }
 }
Esempio n. 8
0
 public void TestGetInstance_DateTimeFormatInfo()
 {
     NodaFormatInfo.ClearCache();
     using (CultureSaver.SetCultures(enUs, FailingCultureInfo.Instance))
     {
         var info = NodaFormatInfo.GetInstance(enGb.DateTimeFormat);
         Assert.AreEqual(enGb.DateTimeFormat, info.DateTimeFormat);
         Assert.AreEqual(CultureInfo.InvariantCulture, info.CultureInfo);
     }
 }
 public void TestGetInstance_null()
 {
     NodaFormatInfo.ClearCache();
     using (CultureSaver.SetCultures(enUs, FailingCultureInfo.Instance))
     {
         var info = NodaFormatInfo.GetInstance(null);
         Assert.AreEqual(Thread.CurrentThread.CurrentCulture, info.CultureInfo);
     }
     using (CultureSaver.SetCultures(enGb, FailingCultureInfo.Instance))
     {
         var info = NodaFormatInfo.GetInstance(null);
         Assert.AreEqual(Thread.CurrentThread.CurrentCulture, info.CultureInfo);
     }
 }
Esempio n. 10
0
        public void CreateWithCurrentCulture()
        {
            var date = new LocalDate(2017, 8, 23);

            using (CultureSaver.SetCultures(Cultures.FrFr))
            {
                var pattern = LocalDatePattern.CreateWithCurrentCulture("d");
                Assert.AreEqual("23/08/2017", pattern.Format(date));
            }
            using (CultureSaver.SetCultures(Cultures.FrCa))
            {
                var pattern = LocalDatePattern.CreateWithCurrentCulture("d");
                Assert.AreEqual("2017-08-23", pattern.Format(date));
            }
        }
Esempio n. 11
0
        public void CreateWithCurrentCulture()
        {
            var od = new LocalDate(2017, 8, 23).WithOffset(Offset.FromHours(2));

            using (CultureSaver.SetCultures(Cultures.FrFr))
            {
                var pattern = OffsetDatePattern.CreateWithCurrentCulture("l<d> o<g>");
                Assert.AreEqual("23/08/2017 +02", pattern.Format(od));
            }
            using (CultureSaver.SetCultures(Cultures.FrCa))
            {
                var pattern = OffsetDatePattern.CreateWithCurrentCulture("l<d> o<g>");
                Assert.AreEqual("2017-08-23 +02", pattern.Format(od));
            }
        }
Esempio n. 12
0
        public void CreateWithCurrentCulture()
        {
            var ot = new LocalTime(12, 34, 56).WithOffset(Offset.FromHours(2));

            using (CultureSaver.SetCultures(Cultures.FrFr))
            {
                var pattern = OffsetTimePattern.CreateWithCurrentCulture("l<t> o<g>");
                Assert.AreEqual("12:34 +02", pattern.Format(ot));
            }
            using (CultureSaver.SetCultures(Cultures.DotTimeSeparator))
            {
                var pattern = OffsetTimePattern.CreateWithCurrentCulture("l<t> o<g>");
                Assert.AreEqual("12.34 +02", pattern.Format(ot));
            }
        }
        public void CreateWithCurrentCulture()
        {
            var dateTime = new LocalDateTime(2017, 8, 23, 12, 34, 56);

            using (CultureSaver.SetCultures(Cultures.FrFr))
            {
                var pattern = LocalDateTimePattern.CreateWithCurrentCulture("g");
                Assert.AreEqual("23/08/2017 12:34", pattern.Format(dateTime));
            }
            using (CultureSaver.SetCultures(Cultures.FrCa))
            {
                var pattern = LocalDateTimePattern.CreateWithCurrentCulture("g");
                Assert.AreEqual("2017-08-23 12:34", pattern.Format(dateTime));
            }
        }
Esempio n. 14
0
        public void CreateWithCurrentCulture()
        {
            var date = new AnnualDate(8, 23);

            using (CultureSaver.SetCultures(Cultures.FrFr))
            {
                var pattern = AnnualDatePattern.CreateWithCurrentCulture("MM/dd");
                Assert.AreEqual("08/23", pattern.Format(date));
            }
            using (CultureSaver.SetCultures(Cultures.FrCa))
            {
                var pattern = AnnualDatePattern.CreateWithCurrentCulture("MM/dd");
                Assert.AreEqual("08-23", pattern.Format(date));
            }
        }
Esempio n. 15
0
        public void CreateWithCurrentCulture()
        {
            var yearMonth = new YearMonth(2017, 8);

            using (CultureSaver.SetCultures(Cultures.EnUs))
            {
                var pattern = YearMonthPattern.CreateWithCurrentCulture("yyyy/MM");
                Assert.AreEqual("2017/08", pattern.Format(yearMonth));
            }
            using (CultureSaver.SetCultures(Cultures.FrCa))
            {
                var pattern = YearMonthPattern.CreateWithCurrentCulture("yyyy/MM");
                Assert.AreEqual("2017-08", pattern.Format(yearMonth));
            }
        }