Skip to content
This repository was archived by the owner on Feb 14, 2020. It is now read-only.

Card day names are one day behind #28

Open
hawkeye217 opened this issue Feb 23, 2019 · 1 comment
Open

Card day names are one day behind #28

hawkeye217 opened this issue Feb 23, 2019 · 1 comment

Comments

@hawkeye217
Copy link

I'm using weather-card with Dark Sky, and all is working correctly except the day names are one day behind (for example, on Friday, the first entry on the card is "THU").

According to the docs for Date.parse here,
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse),

Differences in assumed time zone

Given a date string of "March 7, 2014", parse() assumes a local time zone, but given an ISO format such as "2014-03-07" it will assume a time zone of UTC. Therefore Date objects produced using those strings will represent different moments in time unless the system is set with a local time zone of UTC. This means that two date strings that appear equivalent may result in two different values depending on the format of the string that is being converted (this behavior is changed in ECMAScript ed 6 so that both will be treated as local).

In your code you have this:

                              new Date(daily.datetime).toLocaleDateString(
                                lang,
                                {
                                  weekday: "short"
                                }
                              )

I changed it to:

                              new Date(daily.datetime).toLocaleDateString(
                                lang,
                                {
                                  timeZone: "UTC",
                                  weekday: "short"
                                }
                              )

And now the card displays the correct day. The daily.datetime fields are showing values like 2019-02-22T00:00:00, which seems to be correct. Is this issue specific to me or have others had this issue as well?

@bbrendon
Copy link

I've noticed this too. Right now the first day shown on my phone (ios) is "sat" and on my desktop computer it's "sun". Today is Easter Sunday.

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

No branches or pull requests

2 participants