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