Only include visible series in range selector (#785)
[dygraphs.git] / auto_tests / tests / date_formats.js
... / ...
CommitLineData
1/**
2 * @fileoverview Tests that various formats of date are understood by dygraphs.
3 *
4 * @author dan@dygraphs.com (Dan Vanderkam)
5 */
6
7import * as utils from '../../src/dygraph-utils';
8
9describe("date-formats", function() {
10
11it('testISO8601', function() {
12 // Format: YYYY-MM-DDTHH:MM:SS.ddddddZ
13 // The "Z" indicates UTC, so this test should pass regardless of the time
14 // zone of the machine on which it is run.
15
16 // Firefox <4 does not support this format:
17 // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/parse
18 if (navigator.userAgent.indexOf("Firefox/3.5") == -1) {
19 assert.equal(946816496789, utils.dateParser("2000-01-02T12:34:56.789012Z"));
20 }
21});
22
23it('testHyphenatedDate', function() {
24 // Format: YYYY-MM-DD HH:MM
25
26 // Midnight February 2, 2000, UTC
27 var d = new Date(Date.UTC(2000, 1, 2));
28
29 // Convert to a string in the local time zone: YYYY-DD-MM HH:MM
30 var zp = function(x) { return x < 10 ? '0' + x : x; };
31 var str = d.getFullYear() + '-' +
32 zp(1 + d.getMonth()) + '-' +
33 zp(d.getDate()) + ' ' +
34 zp(d.getHours()) + ':' +
35 zp(d.getMinutes());
36 assert.equal(Date.UTC(2000, 1, 2), utils.dateParser(str));
37});
38
39it('testMillisecondsDate', function() {
40 // Format: YYYY-MM-DD HH:MM:SS.MS
41
42 // Midnight February 2, 2000 14:25:42.123 UTC
43 var ts = Date.UTC(2000, 1, 2, 14, 25, 42, 123);
44 assert.equal("2000/02/02 14:25:42.123", utils.dateString_(ts, true));
45});
46
47});