Created
November 8, 2012 09:16
-
-
Save asfaltboy/4037702 to your computer and use it in GitHub Desktop.
Calculate Percentage of a Trade Day
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
function getTradeDayPercent() { | |
// calculate the percent of time passed since trade opened in sydney | |
gmtoffset = (new Date).getTimezoneOffset() * 60 * 1000; | |
now = Date.now() + gmtoffset; | |
today = new Date(now).set({hour: 0, minute: 0, second: 0}); | |
midnight = today.getTime() | |
hour = parseInt((now - midnight) / 1000 / 60 / 60); | |
if (hour < 17) today.addDays(-1); | |
gmt5 = today.set({hour: 17}); | |
return ((now - gmt5.getTime() + gmtoffset) / 864000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment