-
Notifications
You must be signed in to change notification settings - Fork 117
Events dates are off by one day when running locally #17
Comments
@sebsto thank you for calling attention to this. We'll hopefully be able to internationalize soon. Incase you wanted to take a crack at it, a PR would be tremendous (& if not, no worries 👍 ). Any library recommendations? Thanks again for submitting this issue! |
@sebsto I'm curious if you're still running into this problem––seems like the problem was in part caused by the way newsletters were being generated. We re-created the generation mechanism last week. Hoping this is now resolved. |
I changed my Cloud9 machine's TZ (following instructions at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html)
And can reproduce the problem. So, it is pretty easy for you to reproduce, just spawn a Cloud9 or EC2 instance, change the timezone and voila ! :-) |
@sebsto this is extremely helpful. Will get back to you about this soon. |
I am trying to nail down the root cause, but I am new to Gatsby and I am slow on this :-) Here is my GraphQL query executed in GraphiQL : fragment Contributor on MarkdownRemark {
fields {
key
slug
}
frontmatter {
name
bio
github
twitter
website
}
}
fragment SharedBetweenPostsAndEvents on MarkdownRemark {
fields {
key
slug
date(formatString: "MMMM D, YYYY")
}
frontmatter {
href
title
description
tags
}
}
fragment Event on MarkdownRemark {
...SharedBetweenPostsAndEvents
fields {
attendants {
...Contributor
}
}
frontmatter {
city
country
}
}
query($currentDate: Date!) {
allMarkdownRemark(
sort: {fields: [fields___date], order: ASC}
filter: {fields: {category: {eq: "events"}, date: {gt: $currentDate}}}
) {
edges {
node {
...Event
frontmatter {
platforms
}
}
}
}
} with { "currentDate": "2019-06-01" } And here is a result extract : {
"node": {
"fields": {
"key": "uActwvwBgN5",
"slug": "events/2019/06/11/devdays",
"date": "June 10, 2019",
"attendants": [
{
"fields": {
"key": "2vIVgGdj121",
"slug": "contributors/sebastien-stormacq"
},
"frontmatter": {
"name": "Sébastien Stormacq",
"bio": "Technical Evangelist @ AWS France. Talk about frontend, serverless and identity. https://stormacq.com",
"github": "sebsto",
"twitter": "sebsto",
"website": null
}
}
]
} As you can see :
The directory name is correctly parsed as |
BTW, I don't think it is related, but most of the But the date received here is already incorrect : "context": {
"slug": "events/2019/07/26/addc",
"date": "2019-07-25T22:00:00.000Z"
}, |
@sebsto I don't believe so; Also, in regards to the timezone problem, the solution would probably be to generate many builds for different time zones and feed them up depending on the client. This could be tough to implement. I can't find pre-existing conversations about this problem in Gatsby projects. Feels like a problem with the build paradigm itself. Any other ideas on how we might be able to solve this issue without doing anything at runtime? |
Regarding the date : Gatsby is returning an incorrect date. It takes the date from the slug : 2019-07-26) in this example. It considers the time as being 00:00am GMT. Then it applies the timezone conversion according to client's timezone (for me GMT+2) to calculate the GMT / Zulu time (so minus 2h in this example), which produce a date 2h before the previous day (2019-07-25 22:00 Zulu time)
When the build machine has a local TZ in GMT, the problem does not appear. This is why the public web site is correct. I would suggest to modify the Gatsby module to not make that time conversion. But this is potentially a breaking change for other Gatsby apps. I don't like the idea to generate multiple builds, for each different timezone (24 !) The design best practice is to store time in Zulu time and display in local time to the client app. TZ rendering should be a front end issue. Ideally, Gastby must return the GMT time and we should have client side code to convert it to local or not. Regarding this use case, we can safely assume that event organisers are always going to give the date of their event / conference in local time and people interested to attend the conference are only interested by local time only. So if Gatsby returns whatever the event organiser entered, without conversion, we will be good. |
@sebsto good call & agreed. Thank you for the deep dive! Will fix this asap. |
Gatsby converts stored date to UTC cases the reported dates shifts. This patch is to shows stored date as-is and format date in UI side which is known as a workaround. Fixes: aws-amplify#17 Refs: gatsbyjs/gatsby#11832 (comment)
When running the web site locally, all events are off by one day.
I guess this is a due to a local timezone, my laptop is running in
Here is a screenshot of the hosted version :
Here is a screenshot of my local version :
The text was updated successfully, but these errors were encountered: