1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 const FIREFOX_RELEASE_TIMESTAMP = 1032800850000;
5 const FIREFOX_RELEASE_DATE = new Date(FIREFOX_RELEASE_TIMESTAMP);
7 add_task(function test_date_time_format() {
8 const bundle = new FluentBundle(["en-US"]);
12 dt-arg = Just the arg is: {$dateArg}
13 dt-bare = The bare date is: { DATETIME($dateArg) }
14 dt-month-year = Months and year are not time-zone dependent here: { DATETIME($dateArg, month: "long") }
15 dt-bad = This is a bad month: { DATETIME($dateArg, month: "oops") }
17 dt-timezone = The timezone: { DATETIME($dateArg, timezone: "America/New_York") }
18 dt-unknown = Unknown: { DATETIME($dateArg, unknown: "unknown") }
19 dt-style = Style formatting: { DATETIME($dateArg, dateStyle: "short", timeStyle: "short") }
23 function testMessage(id, dateArg, expectedMessage) {
24 const message = bundle.formatPattern(bundle.getMessage(id).value, {
28 if (typeof expectedMessage === "object") {
31 expectedMessage.test(message),
32 `"${message}" matches regex: ${expectedMessage.toString()}`
36 equal(message, expectedMessage);
40 // TODO - Bug 1707728 - Some of these are implemented as regexes since time zones are not
41 // supported in fluent messages as of yet. They could be simplified if a time zone were
46 /^Just the arg is: (Sun|Mon|Tue) Sep \d+ 2002 \d+:\d+:\d+ .* \(.*\)$/
50 FIREFOX_RELEASE_TIMESTAMP,
51 /^The bare date is: Sep \d+, 2002, \d+:\d+:\d+ (AM|PM)$/
55 FIREFOX_RELEASE_TIMESTAMP,
56 "Months and year are not time-zone dependent here: September"
60 FIREFOX_RELEASE_TIMESTAMP,
61 /^This is a bad month: Sep \d+, 2002, \d+:\d+:\d+ (AM|PM)$/
65 FIREFOX_RELEASE_TIMESTAMP,
66 /^Unknown: Sep \d+, 2002, \d+:\d+:\d+ (AM|PM)$/
70 FIREFOX_RELEASE_TIMESTAMP,
71 /^Style formatting: \d+\/\d+\/\d+, \d+:\d+ (AM|PM)$/
75 // testMessage("dt-timezone", ...);