{"action":"created","issue":{"url":"https://api.github.com/repos/sinonjs/lolex/issues/48","repository_url":"https://api.github.com/repos/sinonjs/lolex","labels_url":"https://api.github.com/repos/sinonjs/lolex/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/sinonjs/lolex/issues/48/comments","events_url":"https://api.github.com/repos/sinonjs/lolex/issues/48/events","html_url":"https://github.com/sinonjs/lolex/issues/48","id":145117947,"number":48,"title":"Faking the timezone","user":{"login":"SystemParadox","id":1228777,"avatar_url":"https://avatars.githubusercontent.com/u/1228777?v=3","gravatar_id":"","url":"https://api.github.com/users/SystemParadox","html_url":"https://github.com/SystemParadox","followers_url":"https://api.github.com/users/SystemParadox/followers","following_url":"https://api.github.com/users/SystemParadox/following{/other_user}","gists_url":"https://api.github.com/users/SystemParadox/gists{/gist_id}","starred_url":"https://api.github.com/users/SystemParadox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SystemParadox/subscriptions","organizations_url":"https://api.github.com/users/SystemParadox/orgs","repos_url":"https://api.github.com/users/SystemParadox/repos","events_url":"https://api.github.com/users/SystemParadox/events{/privacy}","received_events_url":"https://api.github.com/users/SystemParadox/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-01T08:19:50Z","updated_at":"2016-04-01T11:56:22Z","closed_at":null,"body":"How much work would it be to support faking the timezone? Is this even possible?\r\n\r\nOver at node-schedule there are repeated issues due to daylight savings time changes (see https://github.com/node-schedule/node-schedule/issues/267). I was just about to write some tests when I realised that the tests will only work (or rather... only fail!) if the person running the tests also has their timezone set to the same localtime as me. If the timezone is different, the bug will occur at different times. If they are using UTC, the bug will not occur at all.\r\n\r\nSo I would like to be able use lolex and tell it to pretend we are in a particular timezone, regardless of what the system timezone actually is. My suspicion is that this may not even be possible.\r\n\r\nAny thoughts?\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/sinonjs/lolex/issues/comments/204367422","html_url":"https://github.com/sinonjs/lolex/issues/48#issuecomment-204367422","issue_url":"https://api.github.com/repos/sinonjs/lolex/issues/48","id":204367422,"user":{"login":"mantoni","id":332271,"avatar_url":"https://avatars.githubusercontent.com/u/332271?v=3","gravatar_id":"","url":"https://api.github.com/users/mantoni","html_url":"https://github.com/mantoni","followers_url":"https://api.github.com/users/mantoni/followers","following_url":"https://api.github.com/users/mantoni/following{/other_user}","gists_url":"https://api.github.com/users/mantoni/gists{/gist_id}","starred_url":"https://api.github.com/users/mantoni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantoni/subscriptions","organizations_url":"https://api.github.com/users/mantoni/orgs","repos_url":"https://api.github.com/users/mantoni/repos","events_url":"https://api.github.com/users/mantoni/events{/privacy}","received_events_url":"https://api.github.com/users/mantoni/received_events","type":"User","site_admin":false},"created_at":"2016-04-01T11:56:21Z","updated_at":"2016-04-01T11:56:21Z","body":"Ah, I understand. You can set the `TZ` environment variable to set a specific timezone. This works in node and phantomjs like this:\r\n\r\n```bash\r\n$ export TZ='Europe/London‘\r\n$ echo \"console.log(new Date('2016-04-01').toString())\" | node\r\nFri Apr 01 2016 01:00:00 GMT+0100 (BST)\r\n$ echo \"console.log(new Date('2016-04-01').toString())\" | phantomjs\r\nphantomjs> Fri Apr 01 2016 01:00:00 GMT+0100 (BST)\r\n```\r\n\r\nI can see how this is inconvenient if you want to test multiple timezone settings in a single test file.\r\nLolex already mirrors native date properties [like toString](https://github.com/sinonjs/lolex/blob/master/src/lolex-src.js#L129) so this might be a good place to implement fake timezones. I think it’s entirely possible, but it’s not super easy to get right."}}