-
Notifications
You must be signed in to change notification settings - Fork 19
Description
When JavaScript parses dates, it assumes a timezone of UTC whenever it recognises a date string as being a simplification of the ISO 8601 format. e.g. '2000-01-01' is assumed to be in UTC timezone.
However, non-standard date strings are parsed using the browser's local timezone e.g. '1 January 2000' uses your browser's timezone. See example.
This begs the question as to how we should handle any such simplified ISO 8601 dates that a user may enter into a typeable datepicker...
Assuming use-utc is false, should we:
a) Continue with the existing behaviour and allow users to be potentially baffled as to why when they enter a date such as '2000-01-01', depending on their browser's timezone, the datepicker actually selects a date representing the previous day?
b) Try to catch any dates a user enters that the browser may interpret as being in simplified ISO 8601 format and convert them to a local timezone date instead?
Similarly in the scenario where use-utc is true, should we interpret all typed dates as being in UTC timezone, including those which would normally be parsed using the browser's local timezone such as '1 January 2000'?
A further complication:
What about if the user actually specifies a timezone e.g. '1 January 2000 EST' or '2000-01-01T00:00:00.000-05:00'? Should we use it, or not? If we do, we'd need to run all typed dates against a regex to determine whether or not a timezone has been added - and while the [+-]hh:mm scenario could be interpreted reasonably easily, it appears the three letter abbreviations are inconsistent e.g. does BST mean 'British Summer Time' or 'Bangladesh Standard Time'? The only ones I've found Chrome/Firefox to actually use are: UTC, GMT, EDT, EST, CDT, CST, MDT, MST, PDT and PST.