Trying to validate a date using the date rule and feeding ISO8601-valid strings in the following style:
2020-07-24T21:42:04+02:00
2020-07-24T21:42:04-02:00
When we include a positive offset (eg +02:00, +04:00), it doesn't work and displays the error below:
date validation failed on startDate (startDate is my field name)
If we use a negative offset, it works.
If we don't use an offset, it works.
If we pass the Z (00:00), it works.
So the following throws an error:
2020-07-24T21:42:04+02:00
2020-07-24T21:42:04+09:00
These work as expected:
2020-07-24T21:42:04-09:00
2020-07-24T21:42:04-06:00
2020-07-24T21:42:04
2020-07-24T21:42:04Z
Creating a JS date works (new Date("2020-07-23T23:30:45+02:00")), so the rule is expected to accept positive offsets. Am I doing something wrong?
btw, I have also tried using the dateFormat rule with the following format: YYYY-MM-DDTHH:mm:ssZ and I got the same results: it doesn't accept positive offsets.
Package version
^7.4.4
Node.js and npm version
12.14.1 6.14.2
Sample Code (to reproduce the issue)
Trying to validate a date using the
date
rule and feeding ISO8601-valid strings in the following style: 2020-07-24T21:42:04+02:00 2020-07-24T21:42:04-02:00When we include a positive offset (eg +02:00, +04:00), it doesn't work and displays the error below:
date validation failed on startDate
(startDate
is my field name)If we use a negative offset, it works. If we don't use an offset, it works. If we pass the Z (00:00), it works.
So the following throws an error:
These work as expected:
Creating a JS date works (
new Date("2020-07-23T23:30:45+02:00")
), so the rule is expected to accept positive offsets. Am I doing something wrong?