-
Notifications
You must be signed in to change notification settings - Fork 90
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
Added an option to display UTC time instead of local time #38
Conversation
Oops, the tests I wrote rely on the system running them to have a UTC offset of +0100 so the local time displays correctly. I'll work on this more. |
The latest two versions actually pass the tests now, just thought I'd give some insight into what was causing the problem. In order to test whether UTC mode worked I wanted to try and change the timezone. Mockdate allows you to set the timezone offset using its second argument, which I expected to be akin to changing the entire system timezone, however it seems to only alter the value returned by mockdate.set('1987-04-11 04:00', -300)
// On Build Server
new Date().toString() // Sat Apr 11 1987 04:00:00 GMT+0000 (UTC)
new Date().getTimezoneOffset() // -300
// On Local Machine
new Date().toString() // Sat Apr 11 1987 04:00:00 GMT+0100 (BST)
new Date().getTimezoneOffset() // -300 This didn't seem to play nice with the way moment appears handles timezones/offsets. Moment defines two modes, local and UTC. Local is what is used by default or after mockdate.set('1987-04-11 04:00', -300)
// On Build Server
moment().format('H ZZ') // 4 +0500
moment().utc().format('H ZZ') // 4 +0000
// On Local Machine
moment().format('H ZZ') // 4 +0500
moment().utc().format('H ZZ') // 3 +0000 This inconsistency between the hours/ TL;DR: Inconsistencies in hours due to different system timezones played havoc with the tests so now they just ignore the hours |
Latest push just adds a menu item and command to toggle the UTC mode so users can map a key to it if they want |
This is actually right on spot. It is a cool feature, I like it. On a different note, I'll keep #30 still open, as it is originally related to a different feature (also nice, something I'll work on later this week). Cheerio! |
This is working out great for me. Thanks. |
As put forward by @gwax in #30, this adds an option to display the time as UTC time instead of local time. I've included some specs as well as the actual functionality