Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Investigate why the hours are in UTC for East Coast locations #215

Open
JulianNorton opened this issue Oct 1, 2019 · 15 comments
Open

Investigate why the hours are in UTC for East Coast locations #215

JulianNorton opened this issue Oct 1, 2019 · 15 comments

Comments

@JulianNorton
Copy link
Owner

What's the current situation?

Times are not correct

image

"Tomorrow" threshold is on UTC time instead of local time

What do you recommend?

Look into the partial that is breaking up today/tomorrow weather and see if that can be done with local time instead of UTC time.

@ivanfrias
Copy link

can I take this?

@JulianNorton
Copy link
Owner Author

Please do @ivanfrias ! Let me know if you need any help.

@ivanfrias
Copy link

will do, can you assign it to me , please ?

@ivanfrias
Copy link

ivanfrias commented Oct 1, 2019

@JulianNorton moment.unix() converts to a local time. I am based on GTM so it seems to be working fine for me. Is there a better way to verify this behavior? I noticed that at the top the position is set to nyc by default. Maybe we should parse the unix timestamp to the selected position

@JulianNorton
Copy link
Owner Author

JulianNorton commented Oct 1, 2019

@ivanfrias I've had success testing this before via Tor or VPN (to change my location).

I've verified it myself now by looking at New York – it says tomorrow is in 2 hours.

image

I'm not sure where moment.unix() gets it's local time – it's worth looking at the package perhaps?

https://stackoverflow.com/questions/32540667/moment-js-utc-to-local-time

@ivanfrias
Copy link

@JulianNorton OK, I am connected via VPN to US server.

Still, the position doesn't seem to change:

Captura de ecrã 2019-10-01, às 22 52 06

Is there any additional setup I need to do ?

Thx!

@JulianNorton
Copy link
Owner Author

JulianNorton commented Oct 1, 2019 via email

@JulianNorton
Copy link
Owner Author

Hi @ivanfrias
I'm having a hard time replicating this because it's too early! Once it's closer to midnight UTC I'll post another screenshot.

Screen Shot 2019-10-02 at 9 38 07 AM

@JulianNorton
Copy link
Owner Author

JulianNorton commented Oct 2, 2019

Okay so on localhost it seems like the time is fine! I wonder if this has to do with the server time. Any advice @ivanfrias?

@ivanfrias
Copy link

Hey @JulianNorton, it could be. If the google lib fails to get the right timezone of the inbound IP, then undefined is set as the default timezone of moment. If the server is in UTC, then all remaining date/calculations will be based on that.

If there was no 'Change Position' feature we could parse the date on the client side which would use the browser timezone. Locally, the request to get the timezone is blocked because I don't have a GOOGLE_API_KEY. So my question is: how can I get one? Clicking on the link of the ticket ( on the instructions) will take me to Google APIs page but It keeps spinning.

@ivanfrias
Copy link

ivanfrias commented Oct 2, 2019

Interesting: I found that the key is actually commented. Any reason for that ?

 this.setTimeZone = () => {
    return timezone({
      // key: process.env.GOOGLE_API_KEY,
      location: req.params.latitude + ',' + req.params.longitude,
    })
      .then(res => {
        req.params.tz = res.timeZoneId;
        moment.tz.setDefault(req.params.tz);
      });
  };

@JulianNorton
Copy link
Owner Author

7a45fe7 I'm not quite sure why, but in that commit I was removing things like 8pm or 4pm so it would say x hours from now. I can try uncommenting that out locally tomorrow and see what it does!

@JulianNorton
Copy link
Owner Author

JulianNorton commented Oct 4, 2019 via email

@JulianNorton
Copy link
Owner Author

Screen Shot 2019-10-04 at 9 40 15 AM

@ivanfrias
Copy link

hey @JulianNorton, this is an SSL error coming from the google-timezone-api which flags the 'key' as optional but it is not, at least not today, it may have been optional before. Passing a google key doesn't help, as the response is denied on the back-end.

I'll try troubleshooting the lib tonight.

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

No branches or pull requests

2 participants