summaryrefslogtreecommitdiff
path: root/www/js/utils.js
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-07-09 15:55:13 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-07-09 15:55:13 (GMT)
commitc1cdc35285966a7bc9ee7f0fd13d3a8a9bc7cde6 (patch)
tree8185e891b1059893a3cc70bb0d7468f8d2ab637d /www/js/utils.js
parent6998605cd23fce131365ba586493e896814d8e9a (diff)
imporved current week calculation - not finished yet :(
Diffstat (limited to 'www/js/utils.js')
-rw-r--r--www/js/utils.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/www/js/utils.js b/www/js/utils.js
index 09c6333..4f0bb34 100644
--- a/www/js/utils.js
+++ b/www/js/utils.js
@@ -73,6 +73,18 @@ function msToTimeString(time) {
return h + ':' + m.pad(2) + ':' + s.pad(2) + '.' + hs;
}
+function get_tz_offset() {
+ //
+ // This computes the timezone offset for Europe/Vienna
+ // in seconds. This is either 3600 or 7200 depending on
+ // daylight savings time...
+ // For Europe/Vienna daylight saving starts on the last
+ // Sunday in March and ends on the last Sunday in October
+ // always at 3am
+ //
+ return 3600; // TODO: calculate the real offset
+}
+
function get_rd_week() {
//
// This computes the current Rivendell Week based on the number
@@ -81,14 +93,16 @@ function get_rd_week() {
// Explanation:
// epoch was at 01.01.1970 which was a Thursday.
// Monday in that week is (s-from-epoch + 3*24*60*60) seconds ago.
+ // This needs to be adjusted by the timezone offset for Europe/Vienna
+ // which is of course not constant (damn you daylight savings time)
// Divide this by (7*24*60*60) and you get the number of
- // weeks since the Monday in the week of epoch.
+ // weeks since the Monday in the week of epoch adjusted for timezone offsets.
// This week had week number 3 so add an offset of 2 and
// get the modulo of 4. This rounded down gives you the current week
// with 0 meaning Week 1. So add 1 to that number and you will get
// the current RD week.
//
- var sEpoch = (+new Date()) / 1000;
+ var sEpoch = ((+new Date()) / 1000) + get_tz_offset();
var week = Math.floor((((sEpoch + 259200)/604800) + 2) % 4) + 1
return week;
}