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

Converted all date/time handling and tests to use UTC #462

Merged
merged 2 commits into from
Jul 1, 2014
Merged

Converted all date/time handling and tests to use UTC #462

merged 2 commits into from
Jul 1, 2014

Conversation

mdeboer
Copy link
Contributor

@mdeboer mdeboer commented Jun 18, 2014

Fixes annoying timezone and normalization issues.

For example, this is the output I get when I pick a date on the API page and click "Log the select" for June 18, 2014:

{year: 2014, month: 5, date: 18, day: 3, obj: Date 2014-06-17T22:00:00.000Z, pick: 1403042400000}

Take a close look at the difference between "date" and the actual date in the object/pick. I noticed this whilst working on an application and noticed it submitted the dates with a day off. First I thought this was a normalization error but then I realized it was exactly two hours off (my timezone is UTC+2, the Netherlands) and figured it wasn't using UTC dates but local times!

After converting all code and tests to use UTC dates/times everything works as expected and all tests pass. Ran the tests before and after midnight to ensure everything is working as expected. The new API page now gives me the result I expected:

{year: 2014, month: 5, date: 18, day: 3, obj: Date 2014-06-18T00:00:00.000Z, pick: 1403049600000}

As you can see, the time is set to midnight properly and the date obj/pick matches the others.

It is much better and easier to work with UTC values for a date picker, specially when using these values in your application and/or storing it in the database.

Hopefully this can be merged quickly 👍

@amsul
Copy link
Owner

amsul commented Jun 19, 2014

Nice! I was dreading doing it myself - thanks for this 😄

I will merge this in soon

@amsul amsul added the todo label Jun 19, 2014
@amsul amsul added this to the 3.5.3 milestone Jun 19, 2014
@mdeboer
Copy link
Contributor Author

mdeboer commented Jun 19, 2014

You're welcome, glad to help with this amazing time/date picker 👍

amsul added a commit that referenced this pull request Jul 1, 2014
Converted all date/time handling and tests to use UTC
@amsul amsul merged commit 912523c into amsul:dev Jul 1, 2014
@amsul amsul removed the todo label Jul 1, 2014
@amsul amsul modified the milestones: 3.5.4, 3.5.3 Jul 15, 2014
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

Successfully merging this pull request may close these issues.

2 participants