Please enable JavaScript.
Coggle requires JavaScript to display documents.
validate-date, Works for sure for 1901-2099!!! For other intervals may…
validate-date
-
?input
-
match /^(?:(?:31(\/|-|.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|.)(?:0?[13-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/ %input
-
?validateDate.noYear
calc %nowYear=date("Y",%sys.timestamp)
-
Works for sure for 1901-2099!!! For other intervals may have problems with leap years, but It seems it passes tests ok.Matches a date in dd-mm-yyyy format with a choice of 3 separators: . / -. Leap years and month length are also validated. 4 or 2 digits year is ok. General algorithm to check leap year:
- if (year is not divisible by 4) then (it is a common year)
- else if (year is not divisible by 100) then (it is a leap year)
- else if (year is not divisible by 400) then (it is a common year)
- else (it is a leap year)
https://stackoverflow.com/questions/15491894/regex-to-validate-date-format-dd-mm-yyyy-with-leap-year-support #