2 * @fileoverview Tests that various formats of date are understood by dygraphs.
4 * @author dan@dygraphs.com (Dan Vanderkam)
6 var dateFormatsTestCase
= TestCase("date-formats");
8 dateFormatsTestCase
.prototype.setUp
= function() {
11 dateFormatsTestCase
.prototype.tearDown
= function() {
14 dateFormatsTestCase
.prototype.testISO8601
= function() {
15 // Format: YYYY-MM-DDTHH:MM:SS.ddddddZ
16 // The "Z" indicates UTC, so this test should pass regardless of the time
17 // zone of the machine on which it is run.
18 assertEquals(946816496789, Dygraph
.dateParser("2000-01-02T12:34:56.789012Z"));
21 dateFormatsTestCase
.prototype.testHyphenatedDate
= function() {
22 // Format: YYYY-MM-DD HH:MM
24 // Midnight February 2, 2000, UTC
25 var d
= new Date(Date
.UTC(2000, 1, 2));
27 // Convert to a string in the local time zone: YYYY-DD-MM HH:MM
28 var zp
= function(x
) { return x
< 10 ? '0' + x
: x
; };
29 var str
= d
.getFullYear() + '-' +
30 zp(1 + d
.getMonth()) + '-' +
31 zp(d
.getDate()) + ' ' +
32 zp(d
.getHours()) + ':' +
34 assertEquals(Date
.UTC(2000, 1, 2), Dygraph
.dateParser(str
));