1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include "jsapi-tests/tests.h"
11 const char* VALID_DATES
[] = {
20 "2009-05-19T15:00:15",
21 "2009-05-19T15:00-00:00",
22 "2009-05-19T15:00:15.452",
23 "2009-05-19T15:00:15.452Z",
24 "2009-05-19T15:00:15.452+02:00",
25 "2009-05-19T15:00:15.452-02:00",
26 "-271821-04-20T00:00:00Z",
27 "+000000-01-01T00:00:00Z",
30 const char* INVALID_DATES
[] = {
50 "2009-05-19T15:00.25",
56 "2009-05-19T15:00+01",
57 "2009-05-19T10:10+1:00",
58 "2009-05-19T10:10+01:1",
59 "2009-05-19T15:00+75:00",
60 "2009-05-19T15:00+02:80",
64 BEGIN_TEST(testIsISOStyleDate_success
) {
65 for (const char* date
: VALID_DATES
) {
66 CHECK(ValidDate(date
));
68 for (const char* date
: INVALID_DATES
) {
69 CHECK(!ValidDate(date
));
75 bool ValidDate(const char* str
) {
76 return JS::IsISOStyleDate(cx
, JS::Latin1Chars(str
, strlen(str
)));
79 END_TEST(testIsISOStyleDate_success
)