still fixing a scale bar UTC off-by-one error
This commit is contained in:
parent
c3b4d40903
commit
ab6a07d137
1 changed files with 29 additions and 9 deletions
|
@ -85,7 +85,11 @@ Ox.Calendar = function(options, self) {
|
||||||
id: 'millennium',
|
id: 'millennium',
|
||||||
seconds: 365242.5 * 86400,
|
seconds: 365242.5 * 86400,
|
||||||
date: function(i) {
|
date: function(i) {
|
||||||
return new Date(Date.UTC((i + 1) * 1000, 0, 1))
|
var date = new Date();
|
||||||
|
date.setUTCFullYear((i + 1) * 1000);
|
||||||
|
date.setUTCMonth(0);
|
||||||
|
date.setUTCDate(0);
|
||||||
|
return date;
|
||||||
},
|
},
|
||||||
name: function(i) {
|
name: function(i) {
|
||||||
return i > -2
|
return i > -2
|
||||||
|
@ -100,7 +104,11 @@ Ox.Calendar = function(options, self) {
|
||||||
id: 'century',
|
id: 'century',
|
||||||
seconds: 36524.25 * 86400,
|
seconds: 36524.25 * 86400,
|
||||||
date: function(i) {
|
date: function(i) {
|
||||||
return new Date(Date.UTC((i + 19) * 100, 0, 1))
|
var date = new Date();
|
||||||
|
date.setUTCFullYear((i + 19) * 100);
|
||||||
|
date.setUTCMonth(0);
|
||||||
|
date.setUTCDate(0);
|
||||||
|
return date;
|
||||||
},
|
},
|
||||||
name: function(i) {
|
name: function(i) {
|
||||||
return i > -20
|
return i > -20
|
||||||
|
@ -115,7 +123,11 @@ Ox.Calendar = function(options, self) {
|
||||||
id: 'decade',
|
id: 'decade',
|
||||||
seconds: 3652.425 * 86400,
|
seconds: 3652.425 * 86400,
|
||||||
date: function(i) {
|
date: function(i) {
|
||||||
return new Date(Date.UTC((i + 197) * 10, 0, 1))
|
var date = new Date();
|
||||||
|
date.setUTCFullYear((i + 197) * 10);
|
||||||
|
date.setUTCMonth(0);
|
||||||
|
date.setUTCDate(0);
|
||||||
|
return date;
|
||||||
},
|
},
|
||||||
name: function(i) {
|
name: function(i) {
|
||||||
return (i + 197) + '0s'
|
return (i + 197) + '0s'
|
||||||
|
@ -128,7 +140,11 @@ Ox.Calendar = function(options, self) {
|
||||||
id: 'year',
|
id: 'year',
|
||||||
seconds: 365.2425 * 86400,
|
seconds: 365.2425 * 86400,
|
||||||
date: function(i) {
|
date: function(i) {
|
||||||
return new Date(Date.UTC(i + 1970, 0, 1));
|
var date = new Date();
|
||||||
|
date.setUTCFullYear(i + 1970);
|
||||||
|
date.setUTCMonth(0);
|
||||||
|
date.setUTCDate(0);
|
||||||
|
return date;
|
||||||
},
|
},
|
||||||
name: function(i) {
|
name: function(i) {
|
||||||
return (i + 1970) + '';
|
return (i + 1970) + '';
|
||||||
|
@ -141,7 +157,14 @@ Ox.Calendar = function(options, self) {
|
||||||
id: 'month',
|
id: 'month',
|
||||||
seconds: 365.2425 / 12 * 86400,
|
seconds: 365.2425 / 12 * 86400,
|
||||||
date: function(i) {
|
date: function(i) {
|
||||||
return new Date(Date.UTC(Math.floor(i / 12) + 1970, Ox.mod(i, 12), 1));
|
///*
|
||||||
|
var date = new Date();
|
||||||
|
date.setUTCFullYear(Math.floor(i / 12) + 1970);
|
||||||
|
date.setUTCMonth(Ox.mod(i, 12));
|
||||||
|
date.setUTCDate(0);
|
||||||
|
return date;
|
||||||
|
//*/
|
||||||
|
//return new Date(Date.UTC(Math.floor(i / 12) + 1970, Ox.mod(i, 12), 1));
|
||||||
},
|
},
|
||||||
name: function(i) {
|
name: function(i) {
|
||||||
return Ox.SHORT_MONTHS[Ox.mod(i, 12)] + ' ' + Math.floor(i / 12 + 1970)
|
return Ox.SHORT_MONTHS[Ox.mod(i, 12)] + ' ' + Math.floor(i / 12 + 1970)
|
||||||
|
@ -558,7 +581,6 @@ Ox.Calendar = function(options, self) {
|
||||||
var left = Math.max(getPosition(event.start, zoom), -10000),
|
var left = Math.max(getPosition(event.start, zoom), -10000),
|
||||||
paddingLeft = (event.type && left < 0 ? -left : 0),
|
paddingLeft = (event.type && left < 0 ? -left : 0),
|
||||||
width = Ox.limit(getPosition(event.end, zoom) - left, 1, 20000) - paddingLeft;
|
width = Ox.limit(getPosition(event.end, zoom) - left, 1, 20000) - paddingLeft;
|
||||||
Ox.print('LEFT', left, 'WIDTH', width, 'P-LEFT', paddingLeft)
|
|
||||||
return new Ox.Element()
|
return new Ox.Element()
|
||||||
.addClass('OxEvent' +
|
.addClass('OxEvent' +
|
||||||
(event.type ? ' Ox' + Ox.toTitleCase(event.type) : '' ) +
|
(event.type ? ' Ox' + Ox.toTitleCase(event.type) : '' ) +
|
||||||
|
@ -665,7 +687,7 @@ Ox.Calendar = function(options, self) {
|
||||||
width = unit.seconds * getPixelsPerSecond(zoom),
|
width = unit.seconds * getPixelsPerSecond(zoom),
|
||||||
n = Math.ceil(self.options.width * 1.5/* * 16*/ / width);
|
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.print('VALUE', value)
|
||||||
Ox.loop(-n, n + 1, function(i) {
|
Ox.loop(-n, n + 1, function(i) {
|
||||||
$elements.push(
|
$elements.push(
|
||||||
getEventElement({
|
getEventElement({
|
||||||
|
@ -685,7 +707,6 @@ Ox.Calendar = function(options, self) {
|
||||||
// units[1] for background
|
// units[1] for background
|
||||||
var pixelsPerSecond = getPixelsPerSecond(zoom),
|
var pixelsPerSecond = getPixelsPerSecond(zoom),
|
||||||
units;
|
units;
|
||||||
Ox.print(zoom, 'ppsec', pixelsPerSecond)
|
|
||||||
self.units.reverse();
|
self.units.reverse();
|
||||||
Ox.forEach(self.units, function(v, i) {
|
Ox.forEach(self.units, function(v, i) {
|
||||||
width = Math.round(v.seconds * pixelsPerSecond);
|
width = Math.round(v.seconds * pixelsPerSecond);
|
||||||
|
@ -749,7 +770,6 @@ Ox.Calendar = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function panBy(ms) {
|
function panBy(ms) {
|
||||||
Ox.print('panBY', ms)
|
|
||||||
panTo(new Date(+self.options.date + ms));
|
panTo(new Date(+self.options.date + ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue