Getting users timezone on client side and passing it to server side within POST (on challenge complete), showing users stats with users timezone

After CR
This commit is contained in:
JelenaBarinova
2016-01-19 21:11:20 -05:00
parent e02d9d4039
commit 29f93df1bb
12 changed files with 179 additions and 109 deletions

View File

@@ -1,10 +1,10 @@
import moment from 'moment';
import moment from 'moment-timezone';
// day count between two epochs (inclusive)
export function dayCount([head, tail]) {
export function dayCount([head, tail], timezone = 'UTC') {
return Math.ceil(
moment(moment(head).endOf('day')).diff(
moment(tail).startOf('day'),
moment(moment(head).tz(timezone).endOf('day')).tz(timezone).diff(
moment(tail).tz(timezone).startOf('day'),
'days',
true)
);