Skip to content

Instantly share code, notes, and snippets.

@tripp
Created March 15, 2013 02:21
Show Gist options
  • Select an option

  • Save tripp/5167034 to your computer and use it in GitHub Desktop.

Select an option

Save tripp/5167034 to your computer and use it in GitHub Desktop.
Hacks the hour difference for a date range that straddles dst.
function normalizeForDST(dataProvider, key) {
var dateKey = key || "date",
len = dataProvider.length,
dsd = new Date("3/11/2013").valueOf(),
min = new Date(dataProvider[0][dateKey]).valueOf(),
max = new Date(dataProvider[len - 1][dateKey]).valueOf(),
multiplier = (1000 * 60 * 60)/(len - 1),
i,
day;
if(min < dsd && max >= dsd) {
for(i = 1; i < len; i = i + 1) {
dataProvider[i][dateKey] = new Date(dataProvider[i][dateKey]).valueOf() + (multiplier * i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment