Last active
November 6, 2020 06:10
-
-
Save jamesmartin/a648b6ca27017c7d888b to your computer and use it in GitHub Desktop.
Timezone Problems with Timecop and Circle CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# System time zone is set to 'Australia/Sydney' | |
# | |
Time.zone = "Europe/Madrid" | |
=> "Europe/Madrid" | |
Timecop.freeze(Time.zone.now) | |
=> 2015-02-06 23:36:46 +1100 # The "frozen" time. +1100 is Australia/Sydney. Oh dear. | |
Time.zone.now | |
=> Fri, 06 Feb 2015 13:36:46 CET +01:00 # The time here is for the configured Time.zone; Europe/Madrid +01:00 |
Typo in circle.yml
. Should be:
# circle.yml
machine:
timezone:
Europe/Moscow
๐ Just ran into the same issue!
๐
A cleaner version:
machine:
timezone: 'Australia/Sydney'
And if anyone needs it for CircleCI v 2:
environment:
TZ: /usr/share/zoneinfo/America/Los_Angeles
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem:
Tests that freeze time with Timecop pass locally, but fail on Circle CI.
When Timecop freezes time, it uses the system timezone, rather than the
ActiveSupport::TimeZone
configuration (in Rails).The solution:
Configure Circle CI test machines and Rails to use the same Timezone: