Exemplo n.º 1
0
 public void TestGetFormatInfo_null()
 {
     NodaFormatInfo.ClearCache();
     Assert.Throws <ArgumentNullException>(() => NodaFormatInfo.GetFormatInfo(null));
 }
Exemplo n.º 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)));
 }
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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));
Exemplo n.º 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));
Exemplo n.º 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));
Exemplo n.º 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);
Exemplo n.º 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));
Exemplo n.º 10
0
        public void TestEraGetEraPrimaryName_Null()
        {
            var info = NodaFormatInfo.GetFormatInfo(enUs);

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

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

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

            Assert.AreEqual(0, info.GetEraNames(new Era("Ignored", "NonExistantResource")).Count);
        }
Exemplo n.º 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));
Exemplo n.º 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));
 }
Exemplo n.º 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);
Exemplo n.º 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)));
 }
Exemplo n.º 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));
Exemplo n.º 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));
Exemplo n.º 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);
Exemplo n.º 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));
Exemplo n.º 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));
Exemplo n.º 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));
 }
Exemplo n.º 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));
Exemplo n.º 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)));
 }
Exemplo n.º 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)));
 }
Exemplo n.º 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);
Exemplo n.º 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));
Exemplo n.º 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));