コード例 #1
0
        /// <summary>
        /// Check if the day found matches the date.
        /// </summary>
        /// <param name="parseResult">The parse result.</param>
        /// <returns></returns>
        public static bool DayMatchesDate(this BirthDateParseResult parseResult)
        {
            if (!parseResult.Success)
            {
                throw new InvalidOperationException();
            }

            return(!parseResult.DayOfWeekIndex.HasValue || (parseResult.ToDateTime().DayOfWeek == (DayOfWeek)parseResult.DayOfWeekIndex.Value));
        }
コード例 #2
0
        /// <summary>
        /// Convert <see cref="BirthDateParseResult"/> to <see cref="BirthDate"/>.
        /// </summary>
        /// <param name="parseResult">The parse result.</param>
        /// <returns></returns>
        /// <exception cref="FormatException"></exception>
        public static BirthDate ToBirthDate(this BirthDateParseResult parseResult)
        {
            if (!parseResult.Success)
            {
                throw new InvalidOperationException();
            }

            return(new BirthDate(
                       parseResult.ToDateTime(),
                       parseResult.ToBirthDateMaskEnum()
                       ));
        }