-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby): add support for microsecond and alternative iso datetime formats #12533
feat(gatsby): add support for microsecond and alternative iso datetime formats #12533
Conversation
@himynameistimli thanks so much for recreating this PR on our graphql refactoring branch! We'll have a look shortly. |
I've rebased in against master and made this target it, because we merged schema refactoring. I'll merge as soon as this passes CI. Thanks a lot! |
Holy buckets, @himynameistimli — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
I've pulled this PR against this branch per @freiksenet's request
Original Description
When attempting to use
formatString
to format dates in GraphQL, we get "Invalid date", which I believe is due to the precision format of seconds.From what I've seen in other issues/PRs, it seems to be related to the list of formats in type-date.js file. It seems to only have ISO formats with millisecond precision (
YYYY-MM-DDTHHmmss.SSS
). We're using a python backend api for page generation and their default precision is in microseconds (YYYY-MM-DDTHHmmss.SSSSSS
).I've gone and added additional support for
YYYY-MM-DDTHHmmss.SSSSSS
andYYYY-MM-DDTHHmmss.SSSSSSZ
as well as support forYYYY-MM-DD HHmmss.SSSSSS
andYYYY-MM-DD HHmmss.SSSSSSZ
Notes
Per @sidharthachatterjee I tried to add some tests. Please forgive, I'm not so familiar with tests in JS, so I tried to follow from elsewhere to put together the tests. If anyone has any advice or suggestions on how I can improve them, please let me know.
One issue that I've found is after adding the support for microsecond, not only do microseconds validate, but nanoseconds (
YYYY-MM-DDTHHmmss.SSSSSSSSS
) and any precision validates (e.g.2018-08-31T23:25:16.0123456789999+02:00
) as well. I'm not sure how to interpret it, but I've just skipped tests that pass when in theory should fail. I've also commented out explicit nanosecond precision support until the tests can pass.Related Issues
Previous PR #12511
Previous related issue #4813
Should also address #11520 @miktirr plz comment