/// <summary>
        /// Initializes a new instance of the <see cref="BirthDateParse"/> class.
        /// </summary>
        /// <param name="birthDateParseInfo">The birth date parse information.</param>
        /// <param name="formats">The formats.</param>
        public BirthDateParse(BirthDateParseInfo birthDateParseInfo, IList <string> formats = null)
        {
            _birthDateParseInfo = birthDateParseInfo;
            _formats            = formats ?? new List <string> {
                birthDateParseInfo.DefaultFormat
            };

            var cultureInfo = birthDateParseInfo.CultureInfo;

            _dateTimeFormatInfo = DateTimeFormatInfo.GetInstance(cultureInfo);
            _calendar           = cultureInfo.Calendar;

            _threeLetterMonthNames = MakeCleanList(_dateTimeFormatInfo.AbbreviatedMonthNames, _birthDateParseInfo.CultureInfo);
            _fullMonthNames        = MakeCleanList(_dateTimeFormatInfo.MonthNames, _birthDateParseInfo.CultureInfo);
            _threeLetterDayNames   = MakeCleanList(_dateTimeFormatInfo.AbbreviatedDayNames, _birthDateParseInfo.CultureInfo);
            _fullDayNames          = MakeCleanList(_dateTimeFormatInfo.DayNames, _birthDateParseInfo.CultureInfo);
        }
示例#2
0
 /// <summary>
 /// Try get instance of the <see cref="BirthDateParseInfo"/> class using the given <see cref="IFormatProvider"/>.
 /// </summary>
 /// <param name="formatProvider"></param>
 /// <param name="birthDateParseInfo"></param>
 /// <returns></returns>
 internal static bool TryGetInstance(IFormatProvider formatProvider, out BirthDateParseInfo birthDateParseInfo)
 {
     birthDateParseInfo = formatProvider.GetFormat(typeof(BirthDateParseInfo)) as BirthDateParseInfo;
     return(birthDateParseInfo != null);
 }