Created
March 15, 2013 02:21
-
-
Save tripp/5167034 to your computer and use it in GitHub Desktop.
Hacks the hour difference for a date range that straddles dst.
This file contains hidden or 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
| 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