예제 #1
0
 public void TestGetFormatInfo_null()
 {
     NodaFormatInfo.ClearCache();
     Assert.Throws <ArgumentNullException>(() => NodaFormatInfo.GetFormatInfo(null));
 }
예제 #2
0
 /// <summary>
 /// Creates a pattern for the given pattern text and culture.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <returns>A pattern for parsing and formatting instants.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 public static InstantPattern Create(string patternText, CultureInfo cultureInfo)
 {
     return(Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo)));
 }
예제 #3
0
 /// <summary>
 /// Creates a pattern for the given pattern text, culture, resolver, time zone provider, and template value.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// If <paramref name="zoneProvider"/> is null, the resulting pattern can be used for formatting
 /// but not parsing.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <param name="resolver">Resolver to apply when mapping local date/time values into the zone.</param>
 /// <param name="zoneProvider">Time zone provider, used when parsing text which contains a time zone identifier.</param>
 /// <param name="templateValue">Template value to use for unspecified fields</param>
 /// <returns>A pattern for parsing and formatting zoned date/times.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 [NotNull] public static ZonedDateTimePattern Create([NotNull] string patternText, [NotNull] CultureInfo cultureInfo,
                                                     [CanBeNull] ZoneLocalMappingResolver resolver, [CanBeNull] IDateTimeZoneProvider zoneProvider, ZonedDateTime templateValue) =>
 Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo), resolver, zoneProvider, templateValue);
예제 #4
0
 /// <summary>
 /// Creates a pattern for the given pattern text, culture, and template value.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <param name="templateValue">Template value to use for unspecified fields</param>
 /// <returns>A pattern for parsing and formatting local dates.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 public static LocalDatePattern Create([NotNull] string patternText, [NotNull] CultureInfo cultureInfo, LocalDate templateValue) =>
 Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo), templateValue);
예제 #5
0
 /// <summary>
 /// Creates a pattern for the given pattern text and culture.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <returns>A pattern for parsing and formatting offsets.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 public static DurationPattern Create([NotNull] string patternText, [NotNull] CultureInfo cultureInfo) =>
 Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #6
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public LocalTimePattern WithCulture(CultureInfo cultureInfo) =>
 WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #7
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public OffsetPattern WithCulture(CultureInfo cultureInfo) =>
 Create(PatternText, NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #8
0
 /// <summary>
 /// Creates a pattern for the given pattern text, culture, and template value.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <param name="templateValue">Template value to use for unspecified fields</param>
 /// <returns>A pattern for parsing and formatting year/months.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 public static YearMonthPattern Create(string patternText, [ValidatedNotNull] CultureInfo cultureInfo, YearMonth templateValue) =>
 Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo), templateValue);
예제 #9
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public YearMonthPattern WithCulture([ValidatedNotNull] CultureInfo cultureInfo) =>
 WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #10
0
        public void TestEraGetEraPrimaryName_Null()
        {
            var info = NodaFormatInfo.GetFormatInfo(enUs);

            Assert.Throws <ArgumentNullException>(() => info.GetEraPrimaryName(null));
        }
예제 #11
0
 public void ConvertCulture(CultureInfo culture)
 {
     NodaFormatInfo.GetFormatInfo(culture);
 }
예제 #12
0
        public void TestGetEraPrimaryName_NoSuchEra()
        {
            var info = NodaFormatInfo.GetFormatInfo(enUs);

            Assert.AreEqual("", info.GetEraPrimaryName(new Era("Ignored", "NonExistantResource")));
        }
예제 #13
0
        public void TestGetEraPrimaryName()
        {
            var info = NodaFormatInfo.GetFormatInfo(enUs);

            Assert.AreEqual("B.C.", info.GetEraPrimaryName(Era.BeforeCommon));
        }
예제 #14
0
        public void TestGetEraNames_NoSuchEra()
        {
            var info = NodaFormatInfo.GetFormatInfo(enUs);

            Assert.AreEqual(0, info.GetEraNames(new Era("Ignored", "NonExistantResource")).Count);
        }
예제 #15
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public OffsetDatePattern WithCulture(CultureInfo cultureInfo) =>
 WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #16
0
 /// <summary>
 /// Creates a pattern for the given pattern text, culture, resolver, time zone provider, and template value.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// If <paramref name="zoneProvider"/> is null, the resulting pattern can be used for formatting
 /// but not parsing.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <param name="resolver">Resolver to apply when mapping local date/time values into the zone.</param>
 /// <param name="zoneProvider">Time zone provider, used when parsing text which contains a time zone identifier.</param>
 /// <param name="templateValue">Template value to use for unspecified fields</param>
 /// <returns>A pattern for parsing and formatting zoned date/times.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 public static ZonedDateTimePattern Create(string patternText, CultureInfo cultureInfo,
                                           ZoneLocalMappingResolver resolver, IDateTimeZoneProvider zoneProvider, ZonedDateTime templateValue)
 {
     return(Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo), resolver, zoneProvider, templateValue));
 }
예제 #17
0
 /// <summary>
 /// Creates a pattern for the given pattern text, culture, and template value.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <param name="templateValue">Template value to use for unspecified fields</param>
 /// <returns>A pattern for parsing and formatting local times.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 public static LocalTimePattern Create(string patternText, CultureInfo cultureInfo, LocalTime templateValue) =>
 Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo), templateValue);
예제 #18
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public ZonedDateTimePattern WithCulture(CultureInfo cultureInfo)
 {
     return(WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo)));
 }
예제 #19
0
 /// <summary>
 /// Creates a pattern for the given pattern text and culture.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <returns>A pattern for parsing and formatting offsets.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 public static OffsetPattern Create(string patternText, CultureInfo cultureInfo) =>
 Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #20
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public InstantPattern WithCulture([NotNull] CultureInfo cultureInfo) =>
 WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #21
0
 /// <summary>
 /// Creates a pattern for the given pattern text, culture, and template value.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <param name="templateValue">Template value to use for unspecified fields</param>
 /// <returns>A pattern for parsing and formatting local date/times.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 [NotNull] public static OffsetDateTimePattern Create([NotNull] string patternText, [NotNull] CultureInfo cultureInfo, OffsetDateTime templateValue) =>
 Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo), templateValue);
예제 #22
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public OffsetDatePattern WithCulture([ValidatedNotNull] CultureInfo cultureInfo) =>
 WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #23
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public LocalDatePattern WithCulture([NotNull] CultureInfo cultureInfo) =>
 WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #24
0
 /// <summary>
 /// Creates a pattern for the given pattern text, culture, and template value.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <param name="templateValue">Template value to use for unspecified fields</param>
 /// <returns>A pattern for parsing and formatting local dates.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 public static LocalDatePattern Create(string patternText, CultureInfo cultureInfo, LocalDate templateValue)
 {
     return(Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo), templateValue));
 }
예제 #25
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public DurationPattern WithCulture([NotNull] CultureInfo cultureInfo) =>
 Create(PatternText, NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #26
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public LocalDatePattern WithCulture(CultureInfo cultureInfo)
 {
     return(WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo)));
 }
예제 #27
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public InstantPattern WithCulture(CultureInfo cultureInfo)
 {
     return(WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo)));
 }
예제 #28
0
 /// <summary>
 /// Creates a pattern for the given pattern text, culture, and template value.
 /// </summary>
 /// <remarks>
 /// See the user guide for the available pattern text options.
 /// </remarks>
 /// <param name="patternText">Pattern text to create the pattern for</param>
 /// <param name="cultureInfo">The culture to use in the pattern</param>
 /// <param name="templateValue">Template value to use for unspecified fields</param>
 /// <returns>A pattern for parsing and formatting local dates.</returns>
 /// <exception cref="InvalidPatternException">The pattern text was invalid.</exception>
 public static OffsetDatePattern Create(string patternText, CultureInfo cultureInfo, OffsetDate templateValue) =>
 Create(patternText, NodaFormatInfo.GetFormatInfo(cultureInfo), templateValue);
예제 #29
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 [NotNull] public ZonedDateTimePattern WithCulture([NotNull] CultureInfo cultureInfo) =>
 WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo));
예제 #30
0
 /// <summary>
 /// Creates a pattern for the same original pattern text as this pattern, but with the specified
 /// culture.
 /// </summary>
 /// <param name="cultureInfo">The culture to use in the new pattern.</param>
 /// <returns>A new pattern with the given culture.</returns>
 public YearMonthPattern WithCulture(CultureInfo cultureInfo) =>
 WithFormatInfo(NodaFormatInfo.GetFormatInfo(cultureInfo));