public static bool IsLastKindDayOfMonth(this DateTime dateTime, DayOfKind dayOfKind)
        {
            switch (dayOfKind)
            {
            case DayOfKind.Sunday:
            case DayOfKind.Monday:
            case DayOfKind.Tuesday:
            case DayOfKind.Wednesday:
            case DayOfKind.Thursday:
            case DayOfKind.Friday:
            case DayOfKind.Saturday:
                return(dateTime.Day == dateTime.GetLastDayOfWeekOfMonth((DayOfWeek)((int)dayOfKind)).Day);

            case DayOfKind.Day:
                return(dateTime.Day == dateTime.GetLastDayOfMonth().Day);

            case DayOfKind.Weekday:
                return(dateTime.Day == dateTime.GetLastWeekdayOfMonth().Day);

            case DayOfKind.WeekendDay:
                return(dateTime.Day == dateTime.GetLastWeekendDayOfMonth().Day);

            default:
                break;
            }

            return(false);
        }
        public static bool IsFourthKindDayOfMonth(this DateTime target, DayOfKind dayOfKind)
        {
            switch (dayOfKind)
            {
            case DayOfKind.Sunday:
            case DayOfKind.Monday:
            case DayOfKind.Tuesday:
            case DayOfKind.Wednesday:
            case DayOfKind.Thursday:
            case DayOfKind.Friday:
            case DayOfKind.Saturday:
                return(target.Day == target.GetFourthDayOfWeekOfMonth((DayOfWeek)((int)dayOfKind)).Day);

            case DayOfKind.Day:
                return(target.Day == target.GetFourthDayOfMonth().Day);

            case DayOfKind.Weekday:
                return(target.Day == target.GetFourthWeekdayOfMonth().Day);

            case DayOfKind.WeekendDay:
                return(target.Day == target.GetFourthWeekendDayOfMonth().Day);

            default:
                break;
            }

            return(false);
        }
        public static bool IsKindDayOfMonth(this DateTimeOffset dateTime, DayOfMonth dayOfMonth, DayOfKind dayOfKind)
        {
            switch (dayOfMonth)
            {
            case DayOfMonth.First:
                return(IsFirstKindDayOfMonth(dateTime, dayOfKind));

            case DayOfMonth.Second:
                return(IsSecondKindDayOfMonth(dateTime, dayOfKind));

            case DayOfMonth.Third:
                return(IsThirdKindDayOfMonth(dateTime, dayOfKind));

            case DayOfMonth.Fourth:
                return(IsFourthKindDayOfMonth(dateTime, dayOfKind));

            case DayOfMonth.Fifth:
            case DayOfMonth.Sixth:
            case DayOfMonth.Seventh:
            case DayOfMonth.Eighth:
            case DayOfMonth.Ninth:
            case DayOfMonth.Tenth:
            case DayOfMonth.Eleventh:
            case DayOfMonth.Twelfth:
            case DayOfMonth.Thirteenth:
            case DayOfMonth.Fourteenth:
            case DayOfMonth.Fifteenth:
            case DayOfMonth.Sixteenth:
            case DayOfMonth.Seventeenth:
            case DayOfMonth.Eighteenth:
            case DayOfMonth.Nineteenth:
            case DayOfMonth.Twentieth:
            case DayOfMonth.TwentyFirst:
            case DayOfMonth.TwentySecond:
            case DayOfMonth.TwentyThird:
            case DayOfMonth.TwentyFourth:
            case DayOfMonth.TwentyFifth:
            case DayOfMonth.TwentySixth:
            case DayOfMonth.TwentySeventh:
            case DayOfMonth.TwentyEighth:
            case DayOfMonth.TwentyNineth:
            case DayOfMonth.Thirtieth:
            case DayOfMonth.ThirtyFirst:
            {
                if (dayOfKind != DayOfKind.Day)
                {
                    throw new InvalidProgramException("Does not support given kind of day.");
                }

                int day = (int)dayOfMonth;
                return(dateTime.Day == day);
            }

            case DayOfMonth.Last:
                return(IsLastKindDayOfMonth(dateTime, dayOfKind));

            default:
                break;
            }

            throw new InvalidProgramException("Cannot parse the given month and day.");
        }