Пример #1
0
        public static IEnumerable <ZonedDateTimePattern> GetZonedDateTimePatterns(CultureInfo cultureInfo = null, IDateTimeZoneProvider dateTimeZoneProvider = null)
        {
            if (dateTimeZoneProvider == null)
            {
                dateTimeZoneProvider = DateTimeZoneProvider;
            }

            int l = _zonedDateTimePatterns.Length;

            ZonedDateTimePattern[] patterns = new ZonedDateTimePattern[l];
            // Default, culture invariant parsers
            for (int i = 0; i < l; i++)
            {
                ZonedDateTimePattern pattern = _zonedDateTimePatterns[i].WithZoneProvider(dateTimeZoneProvider);
                yield return(pattern);

                patterns[i] = pattern;
            }

            // Get specific culture
            if (cultureInfo == null)
            {
                cultureInfo = CultureInfo.CurrentCulture;
            }
            if (cultureInfo.IsInvariant())
            {
                yield break;
            }

            // Culture specific patterns
            foreach (ZonedDateTimePattern pattern in patterns)
            {
                yield return(pattern.WithCulture(cultureInfo));
            }
        }