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

Beware of time zone #9

Open
armandofox opened this issue Jun 21, 2014 · 0 comments
Open

Beware of time zone #9

armandofox opened this issue Jun 21, 2014 · 0 comments
Labels

Comments

@armandofox
Copy link
Contributor

If you're coding any functionality that has a dependency on time of day, do not use Time.now to mean the current time!

The reason is that Time.now returns the current time in the timezone where this computer (the one running the test) is located, but what you want is the time in the application's time zone.

We are making the application's time zone UTC (basically, GMT) since we will have users in all different time zones and each user can set the TZ in which they view and enter times. All times will be stored as UTC, and all time-dependent tasks will reckon time in UTC.

Therefore please use Time.zone.now to get the current time. Here is a good article on this gotcha. I've modified the Gemfile to include the timecop gem, which you can use to stub the clock in your tests.

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

No branches or pull requests

1 participant