Пример #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));