Rock.RockDateTime.New C# (CSharp) Method

New() public static method

Creates a new datetime based on year, month, day, and handles 2/29 for non leap years (returns 2/28 in this case)
public static New ( int year, int month, int day ) : DateTime?
year int The year.
month int The month.
day int The day.
return DateTime?
        public static DateTime? New( int year, int month, int day )
        {
            try
            {
                if ( !DateTime.IsLeapYear( year ) && month == 2 && day == 29 )
                {
                    return new DateTime( year, 2, 28 );
                }
                return new DateTime( year, month, day );
            }
            catch { }

            return (DateTime?)null;
        }