public static Try <DateTime> TryCreateDate(Year year, Month month, Day day) => () => { return(new DateTime(year.Value, month.Value, day.Value)); };
public static Validation <string, DateTime> ValidateAndCreateDate(Year year, Month month, Day day) { if (year.Value >= 2000 && year.Value <= 2100 && month.Value >= 1 && month.Value <= 12 && day.Value >= 1 && day.Value <= DateTime.DaysInMonth(year.Value, month.Value)) { return(Success <string, DateTime>(new DateTime(year.Value, month.Value, day.Value))); } else { return(Fail <string, DateTime>("Invalid date")); } }
public static DateTime CreateDate(Year year, Month month, Day day) { return(new DateTime(year.Value, month.Value, day.Value)); }