Esempio n. 1
0
 public static Try <DateTime> TryCreateDate(Year year, Month month, Day day)
 => () =>
 {
     return(new DateTime(year.Value, month.Value, day.Value));
 };
Esempio n. 2
0
 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"));
     }
 }
Esempio n. 3
0
 public static DateTime CreateDate(Year year, Month month, Day day)
 {
     return(new DateTime(year.Value, month.Value, day.Value));
 }