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:
@@ -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)
|
||||
);
|
||||
|
Reference in New Issue
Block a user