Created
February 8, 2010 15:13
-
-
Save whym/298220 to your computer and use it in GitHub Desktop.
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
| var now = new Date(); | |
| var last_nyd = new Date(now.getFullYear(), 0, 1); | |
| var next_nyd = new Date(now.getFullYear() + 1, 0, 1); | |
| var rate = (now - last_nyd) / (next_nyd - last_nyd); | |
| var beginning_of_today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); | |
| var one_day = 1000 * 60 * 60 * 24; | |
| var pdate = new Date(beginning_of_today.getTime() + rate * one_day); | |
| var hours = pdate.getHours(); | |
| var ampm = hours > 12 ? "PM" : "AM"; | |
| hours = hours > 12 ? hours - 12 : hours; | |
| alert("You spent " + ((rate*1000|0) / 10) + "% of this year.\n" + | |
| "If a year were a day, it would be " + hours +":"+ pdate.getMinutes() +":"+ pdate.getSeconds() +"."+ pdate.getMilliseconds() +" "+ ampm + " now."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment