Last active
June 15, 2017 05:23
-
-
Save keewon/b8b028aa777cba4dc125a0e94edb0f7a to your computer and use it in GitHub Desktop.
fix Tapjoy v2 dashboard date range bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* https://dashboard.tapjoy.com/dashboard/v2/advertise/list?start=2017-05-23&end=2017-05-27&granularity=1.day&range=custom */ | |
/* use this site to create bookmarklet - http://mrcoles.com/bookmarklet/ */ | |
require.s.contexts._.defined['lib/models/ad_filter'].prototype.computeDates = function(range) { | |
var dateFormat, endDate, endDateString, isOneDayHourly, number_and_word_range, startDate, startDateString, timezone; | |
if (range == null) { | |
range = null | |
} | |
range || (range = this.get("range")); | |
number_and_word_range = /^(\d+)(\w+)$/.exec(range); | |
endDate = moment(this.get("end")).endOf("day").max(moment()); | |
startDate = moment(this.get("start")).startOf("day"); | |
dateFormat = "YYYY-MM-DD"; | |
if (number_and_word_range) { | |
endDate = moment().startOf("hour"); | |
startDate = moment(endDate).subtract(number_and_word_range[2], number_and_word_range[1]); | |
if (range === "6day") { | |
startDate.startOf("day") | |
} | |
isOneDayHourly = this.isHourly() && range === "1day"; | |
if (isOneDayHourly) { | |
startDate = startDate.add(1, "hour") | |
} | |
} | |
if (this.isHourly()) { | |
dateFormat = "YYYY-MM-DDTHH:mm:ssZ" | |
} else { | |
timezone = moment().format('Z'); | |
if (timezone.substr(0, 1) !== '+') { | |
endDate = endDate.utc(); | |
startDate = startDate.utc() | |
} | |
} | |
startDateString = startDate.format(dateFormat); | |
endDateString = endDate.format(dateFormat); | |
console.log("startDateString:" + startDateString); | |
console.log("endDateString:" + endDateString); | |
return this.set({ | |
start: startDateString, | |
end: endDateString | |
}, { | |
silent: true | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment