From c3b4d40903365fd9fbd64818db0646a20b84047b Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 25 May 2011 23:31:10 +0200 Subject: [PATCH] fix a scale bar UTC off-by-one error --- source/Ox.UI/js/Calendar/Ox.Calendar.js | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/source/Ox.UI/js/Calendar/Ox.Calendar.js b/source/Ox.UI/js/Calendar/Ox.Calendar.js index 87555944..2a9257f2 100644 --- a/source/Ox.UI/js/Calendar/Ox.Calendar.js +++ b/source/Ox.UI/js/Calendar/Ox.Calendar.js @@ -85,9 +85,7 @@ Ox.Calendar = function(options, self) { id: 'millennium', seconds: 365242.5 * 86400, date: function(i) { - var date = new Date(1970, 0, 1); - date.setUTCFullYear((i + 1) * 1000); - return date; + return new Date(Date.UTC((i + 1) * 1000, 0, 1)) }, name: function(i) { return i > -2 @@ -102,9 +100,7 @@ Ox.Calendar = function(options, self) { id: 'century', seconds: 36524.25 * 86400, date: function(i) { - var date = new Date(1970, 0, 1); - date.setUTCFullYear((i + 19) * 100); - return date; + return new Date(Date.UTC((i + 19) * 100, 0, 1)) }, name: function(i) { return i > -20 @@ -119,9 +115,7 @@ Ox.Calendar = function(options, self) { id: 'decade', seconds: 3652.425 * 86400, date: function(i) { - var date = new Date(1970, 0, 1); - date.setUTCFullYear((i + 197) * 10); - return date; + return new Date(Date.UTC((i + 197) * 10, 0, 1)) }, name: function(i) { return (i + 197) + '0s' @@ -134,7 +128,7 @@ Ox.Calendar = function(options, self) { id: 'year', seconds: 365.2425 * 86400, date: function(i) { - return '01/01/' + (i + 1970) + ' UTC'; + return new Date(Date.UTC(i + 1970, 0, 1)); }, name: function(i) { return (i + 1970) + ''; @@ -147,9 +141,7 @@ Ox.Calendar = function(options, self) { id: 'month', seconds: 365.2425 / 12 * 86400, date: function(i) { - var date = new Date(1970, Ox.mod(i, 12), 1); - date.setUTCFullYear(Math.floor(i / 12) + 1970) - return date; + return new Date(Date.UTC(Math.floor(i / 12) + 1970, Ox.mod(i, 12), 1)); }, name: function(i) { return Ox.SHORT_MONTHS[Ox.mod(i, 12)] + ' ' + Math.floor(i / 12 + 1970) @@ -566,7 +558,7 @@ Ox.Calendar = function(options, self) { var left = Math.max(getPosition(event.start, zoom), -10000), paddingLeft = (event.type && left < 0 ? -left : 0), width = Ox.limit(getPosition(event.end, zoom) - left, 1, 20000) - paddingLeft; - //Ox.print('LEFT', left, 'WIDTH', width) + Ox.print('LEFT', left, 'WIDTH', width, 'P-LEFT', paddingLeft) return new Ox.Element() .addClass('OxEvent' + (event.type ? ' Ox' + Ox.toTitleCase(event.type) : '' ) + @@ -672,7 +664,8 @@ Ox.Calendar = function(options, self) { value = unit.value(self.options.date), width = unit.seconds * getPixelsPerSecond(zoom), n = Math.ceil(self.options.width * 1.5/* * 16*/ / width); - Ox.print(zoom, getUnits(zoom).map(function(u) {return u.name(value)}).join('/')) + //Ox.print(zoom, getUnits(zoom).map(function(u) {return u.name(value)}).join('/')) + Ox.print('VALUE', value) Ox.loop(-n, n + 1, function(i) { $elements.push( getEventElement({ @@ -717,7 +710,7 @@ Ox.Calendar = function(options, self) { title = '' + event.name + '
' + formatEvent(event); } else { - title = Ox.formatDate(getMouseDate(e), '%a, %b %e, %Y, %H:%M:%S'); + title = Ox.formatDate(getMouseDate(e), '%a, %b %e, %Y, %H:%M:%S', true); } self.$tooltip.options({ title: title