| 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | |
| 5 | var gStardate, gSDBase; |
| 6 | |
| 7 | window.onload = function() { |
| 8 | setTimeout(updateStardate, 0); |
| 9 | } |
| 10 | |
| 11 | function updateStardate() { |
| 12 | if (!gStardate) |
| 13 | gStardate = document.getElementById("stardate"); |
| 14 | |
| 15 | var curDate = new Date(); |
| 16 | |
| 17 | if (!gSDBase) |
| 18 | gSDBase = new Date("September 8, 1966 20:00:00 EST"); |
| 19 | |
| 20 | var sdateval = (curDate - gSDBase) / (86400 * 365.2425); |
| 21 | gStardate.textContent = sdateval.toFixed(1); |
| 22 | |
| 23 | setTimeout(updateStardate, 5*60*1000); |
| 24 | } |