Skip to content
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

Consider making DateTime be tz-agnostic, and adding DateTimeTz for tz-aware timestamps? #1

Open
obi1kenobi opened this issue May 29, 2020 · 1 comment

Comments

@obi1kenobi
Copy link

First, thank you for starting this project — I think it's something the GraphQL community definitely needs to have.

I'd like to propose a tweak: make DateTime be timezone-agnostic (i.e. unaware of its UTC offset), and introduce a DateTimeTz scalar type that requires a UTC offset to be specified. This is the change that the GraphQL compiler project settled on after long discussions on the topic, and we wrote up our proposed definition for DateTimeTz here: kensho-technologies/graphql-compiler#829

Some of our considerations:

  • Some programming languages (e.g. Python) do not require UTC offset / timezone information to be set on datetimes, and DateTimeTz as a name is more explicit about this requirement.
  • Some query languages (e.g. SQL) default to not carrying UTC offset / timezone information unless specifically mentioned in the name of the type. For example, in the SQL standard, timestamp is equivalent to timestamp without time zone, and to get time zone info, you must use the type timestamp with time zone or an abbreviation like timestamptz: https://www.postgresql.org/docs/current/datatype-datetime.html
  • Because of the above, we were concerned about potential confusion — users used to SQL and/or Python may incorrectly assume that DateTime either explicitly does not contain time zone info (a la SQL), or is allowed but not required to contain it (a la Python). Being explicit about the existence of a scalar DateTimeTz type immediately allows the user to set correct expectations about scalar DateTime as well.
@andimarek
Copy link
Owner

I agree that DateTime is not a perfect name, but I want to point out that this is the name of the spec and not necessarily the name of the Scalar. The Scalar can be named how ever people want.

The GraphQL community uses mostly DateTime which represent a RFC3339/ISO 8601 formatted value with offset, this is why the name DateTime what chosen.

I think we will add more Date related scalars, namely LocalDateTime (again: the name of the spec, not the name of the Scalar) which will represent a date time without offset or time zone.

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

2 participants