alex35mil / sourcebuster-js

Track the sources of your traffic
https://alexfedoseev.github.io/sbjs
MIT License
413 stars 93 forks source link

Set timezone_offset to UTC #7

Closed RNACode closed 8 years ago

RNACode commented 8 years ago

It is possible to set timezone to UTC? I will try init sbjs with this parameters: sbjs.init({ timezone_offset: 0 }); But it does not change time zone to UTC. I saw sources and found: `... setDate: function(date, offset) { var utc_offset = date.getTimezoneOffset() / 60, now_hours = date.getHours(), custom_offset = offset || -utc_offset;

date.setHours(now_hours + utc_offset + custom_offset);

var year    = date.getFullYear(),
    month   = this.setLeadingZeroToInt(date.getMonth() + 1,   2),
    day     = this.setLeadingZeroToInt(date.getDate(),        2),
    hour    = this.setLeadingZeroToInt(date.getHours(),       2),
    minute  = this.setLeadingZeroToInt(date.getMinutes(),     2),
    second  = this.setLeadingZeroToInt(date.getSeconds(),     2);

return (year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second);

}, ...` In this case
custom_offset = offset || -utc_offset; // -utc_offset

alex35mil commented 8 years ago

It is possible to set timezone to UTC? I will try init sbjs with this parameters: sbjs.init({ timezone_offset: 0 });

@RNACode This one supposed to do it. It doesn't only for UTC 0 case b/c: https://github.com/alexfedoseev/sourcebuster-js/blob/master/src/js/helpers/utils.js#L12, but 0 is falsy. It would be great, if you can submit PR w/ fix, b/c I'm currently busy on project. Thanks!