Make Entries enforce specific DateTime string format during runtime
This is not about linting but about checks at runtime! :D
Entry is the js class that handles user answers to questions. Raw answer data is given by an EntryConfig and stored as JSON.stringify(entryConfig). Entries should enforce the proper DateTime string format in EntryConfigs such that JSON.stringify cannot produce bad values.
Example of mishap: For the target day EntryConfig gets handed a js Date object instead of YYYY-MM-DD
string. JSON.stringify will turn that into an ISO string like this: 2022-11-24T17:13:30.960Z
defaulting to UTC. This can still be parsed as a date, but will break things when the local time zone is ahead of UTC, e.g, UTC+1 (notice the date change!):
JSON.stringify(new Date('2022-11-23T00:00:00')) === "2022-11-22T23:00:00.000Z"
EntryConfig should also not accept ISO strings ending a Z
. Instead theses strings should end in +00:00. It's the same thing and both are valid ISO 8601 strings but the former could have been created by toISOString (resp. JSON.stringfy()) defaulting to UTC. Or the other way around: A Z
at the end of the string is warning sign, that some method previously defaulted to UTC.