-
- // Choose appropiate date methods according to UTC or local time option.
- // weekday: return the day of week from a Date object.
- // decompose_date: decompose a Date object into an array of datefields.
- // compose_date: compose a Date object from an array of date fields.
- var compose_date, decompose_date, weekday;
- if (utc) {
- weekday = function (d) {
- return d.getUTCDay();
- };
- decompose_date = function (d) {
- var a = [];
- a[Dygraph.DATEFIELD_Y] = d.getUTCFullYear();
- a[Dygraph.DATEFIELD_M] = d.getUTCMonth();
- a[Dygraph.DATEFIELD_D] = d.getUTCDate();
- a[Dygraph.DATEFIELD_HH] = d.getUTCHours();
- a[Dygraph.DATEFIELD_MM] = d.getUTCMinutes();
- a[Dygraph.DATEFIELD_SS] = d.getUTCSeconds();
- a[Dygraph.DATEFIELD_MS] = d.getUTCMilliseconds();
- return a;
- };
- compose_date = function (a) {
- var d = new Date(Date.UTC(a[Dygraph.DATEFIELD_Y],
- a[Dygraph.DATEFIELD_M],
- a[Dygraph.DATEFIELD_D],
- a[Dygraph.DATEFIELD_HH],
- a[Dygraph.DATEFIELD_MM],
- a[Dygraph.DATEFIELD_SS],
- a[Dygraph.DATEFIELD_MS]));
- return d;
- };
- } else {
- weekday = function(d) {
- return d.getDay();
- };
- decompose_date = function (d) {
- var a = [];
- a[Dygraph.DATEFIELD_Y] = d.getFullYear();
- a[Dygraph.DATEFIELD_M] = d.getMonth();
- a[Dygraph.DATEFIELD_D] = d.getDate();
- a[Dygraph.DATEFIELD_HH] = d.getHours();
- a[Dygraph.DATEFIELD_MM] = d.getMinutes();
- a[Dygraph.DATEFIELD_SS] = d.getSeconds();
- a[Dygraph.DATEFIELD_MS] = d.getMilliseconds();
- return a;
- };
- compose_date = function (a) {
- var d = new Date(a[Dygraph.DATEFIELD_Y],
- a[Dygraph.DATEFIELD_M],
- a[Dygraph.DATEFIELD_D],
- a[Dygraph.DATEFIELD_HH],
- a[Dygraph.DATEFIELD_MM],
- a[Dygraph.DATEFIELD_SS],
- a[Dygraph.DATEFIELD_MS]);
- return d;
- };
- }
-