ucberkeley / moocchat

SaaS app for integrating peer learning/peer discussion into MOOCs and similar settings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Beware of time zone

armandofox opened this issue · comments

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.