Skip to content

Commit 40f5f23

Browse files
committed
Revert period range timezone changes
1 parent f3cf37c commit 40f5f23

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

api/lib/countly.common.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,7 @@ countlyCommon.getPeriodRange = function(period, timezone, offset) {
913913

914914
endTimestamp = excludeCurrentDay ? __currMoment.clone().subtract(1, 'days').endOf('day') : __currMoment.clone().endOf('day');
915915

916-
var isRangePeriod = Array.isArray(period);
917-
918-
if (isRangePeriod) {
916+
if (Array.isArray(period)) {
919917
if ((period[0] + "").length === 10) {
920918
period[0] *= 1000;
921919
}
@@ -996,24 +994,15 @@ countlyCommon.getPeriodRange = function(period, timezone, offset) {
996994
let nDays = 30;
997995
startTimestamp = __currMoment.clone().startOf("day").subtract(nDays - 1, "days");
998996
}
999-
var startOffset = offset;
1000-
var endOffset = offset;
1001-
1002-
if (timezone && isRangePeriod) {
1003-
startOffset = moment.tz(startTimestamp.valueOf(), timezone).utcOffset() * -1;
1004-
endOffset = moment.tz(endTimestamp.valueOf(), timezone).utcOffset() * -1;
997+
if (!offset) {
998+
offset = moment.tz(timezone).utcOffset();
999+
offset = offset * -1;
10051000
}
1006-
else if (typeof offset !== "number") {
1007-
offset = timezone ? moment.tz(timezone).utcOffset() * -1 : 0;
1008-
startOffset = offset;
1009-
endOffset = offset;
1010-
}
1011-
10121001
return {
1013-
"$gt": startTimestamp.valueOf() + startOffset * 60000 - 1,
1014-
"$lt": endTimestamp.valueOf() + endOffset * 60000 + 1,
1015-
"$gte": startTimestamp.valueOf() + startOffset * 60000,
1016-
"$lte": endTimestamp.valueOf() + endOffset * 60000,
1002+
"$gt": startTimestamp.valueOf() + offset * 60000 - 1,
1003+
"$lt": endTimestamp.valueOf() + offset * 60000 + 1,
1004+
"$gte": startTimestamp.valueOf() + offset * 60000,
1005+
"$lte": endTimestamp.valueOf() + offset * 60000,
10171006
};
10181007
};
10191008

test/unit/api.utils.common.unit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ describe("Common API utility functions", function() {
447447
var timezone = "America/New_York";
448448
var offset = 300;
449449
var range = countlyCommon.getPeriodRange(getPeriod(), timezone, offset);
450-
assertRange(range, timezone);
450+
assertRange(range, timezone, offset);
451451
});
452452

453453
describe("with different server default timezone", function() {

0 commit comments

Comments
 (0)