Skip to content

Proposal: date-time format that requires timezone information #1498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zlamma opened this issue Mar 1, 2018 · 3 comments
Closed

Proposal: date-time format that requires timezone information #1498

zlamma opened this issue Mar 1, 2018 · 3 comments

Comments

@zlamma
Copy link

zlamma commented Mar 1, 2018

The date-time format allows both local and 'timezoned' values (both are allowed by ISO_8601).

Although there can be use cases where local time is desired (say, flight arrival time at destination, without having to know the timezone offset at that date), in a great number of cases allowing the lack of timezone information is undesired, because it is unclear what the local time is supposed to be (browser clients can be in any timezone).

In fact, from my experience, sending a 'timezoneless' value will most often be a sign of a bug in the client (someone forgetting to use a proper UTC backed value or forgot to apply correct formatting), while the server accepting such a value will be a bug on the server - insufficient validation. Both of them combined will inevitably lead to a hard-to-spot data corruption.

  1. The proposal is to create a separate format that forbids passing values without timezone indicator.
    • Name could be: date-time-localizable, date-time-convertible, date-time-tz, but feel free to suggest better ones.
  2. Also, one could argue that, even though a use case for local time does exist (as the flight arrival example shows), a developer of such service would find it useful to bounce back any requests that contain the timezone designator, because it too might be a sign of user performing an inadvertent conversion (e.g. using JavaScript Date() on the local client and not preventing the conversion that some libraries can choose to perform 'by default').
    • A name for this could date-time-local or date-time-no-tz, date-time-without-tz, date-time-tz-free.

(I'm especially interested in number 1. Number 2 is mostly as a side-suggestion to get feedback for.)

@MikeRalphson
Copy link
Member

MikeRalphson commented Mar 1, 2018

Refs #1345 , #845

@handrews
Copy link
Member

handrews commented Mar 1, 2018

JSON Schema's date-time is based on RFC 3339 which is a subset of ISO 8601. I'm having trouble sorting through the ABNFs as I have not yet had enough cups of tea this morning for that sort of thing, but I think that while the time zone portion ("Z" or an offset) is optional in ISO 8601, it is not optional in RFC 3339 for the date-time production that JSON Schema references.

Am I misreading this?

@zlamma
Copy link
Author

zlamma commented Mar 1, 2018

Hi @handrews . You are correct indeed! I assumed otherwise because Newtonsoft JSON doesn't even have an option to enforce it, while it is the de-facto standard JSON serialization library for .NET (even Microsoft uses it for ASP.NET Core framework).

Looks like I need to raise it with them then :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants