format_range_hour_cycle.js 7.18 KB
Newer Older
Frank Tang's avatar
Frank Tang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

let midnight = new Date(2019, 3, 4, 0);
let noon = new Date(2019, 3, 4, 12);
let df_11 = new Intl.DateTimeFormat(
    "en", {hour: "numeric", minute: "numeric", hourCycle: "h11"})
assertEquals("h11", df_11.resolvedOptions().hourCycle);
assertEquals("0:00 AM", df_11.formatRange(midnight, midnight));
assertEquals("0:00 PM", df_11.formatRange(noon, noon));

let df_11_t = new Intl.DateTimeFormat(
    "en", {timeStyle: "short", hourCycle: "h11"})
assertEquals("h11", df_11_t.resolvedOptions().hourCycle);
assertEquals("0:00 AM", df_11_t.formatRange(midnight, midnight));
assertEquals("0:00 PM", df_11_t.formatRange(noon, noon));

let df_11_dt = new Intl.DateTimeFormat(
    "en", {timeStyle: "short", dateStyle: "short", hourCycle: "h11"})
assertEquals("h11", df_11_dt.resolvedOptions().hourCycle);
assertEquals("4/4/19, 0:00 AM", df_11_dt.formatRange(midnight, midnight));
assertEquals("4/4/19, 0:00 PM", df_11_dt.formatRange(noon, noon));

let df_12 = new Intl.DateTimeFormat(
    "en", {hour: "numeric", minute: "numeric", hourCycle: "h12"})
assertEquals("h12", df_12.resolvedOptions().hourCycle);
assertEquals("12:00 AM", df_12.formatRange(midnight, midnight));
assertEquals("12:00 PM", df_12.formatRange(noon, noon));

let df_12_t = new Intl.DateTimeFormat(
    "en", {timeStyle: "short", hourCycle: "h12"})
assertEquals("h12", df_12_t.resolvedOptions().hourCycle);
assertEquals("12:00 AM", df_12_t.formatRange(midnight, midnight));
assertEquals("12:00 PM", df_12_t.formatRange(noon, noon));

let df_12_dt = new Intl.DateTimeFormat(
    "en", {timeStyle: "short", dateStyle: "short", hourCycle: "h12"})
assertEquals("h12", df_12_dt.resolvedOptions().hourCycle);
assertEquals("4/4/19, 12:00 AM", df_12_dt.formatRange(midnight, midnight));
assertEquals("4/4/19, 12:00 PM", df_12_dt.formatRange(noon, noon));

let df_23 = new Intl.DateTimeFormat(
    "en", {hour: "numeric", minute: "numeric", hourCycle: "h23"})
assertEquals("h23", df_23.resolvedOptions().hourCycle);
assertEquals("00:00", df_23.formatRange(midnight, midnight));
assertEquals("12:00" ,df_23.formatRange(noon, noon));

let df_23_t = new Intl.DateTimeFormat(
    "en", {timeStyle: "short", hourCycle: "h23"})
assertEquals("h23", df_23_t.resolvedOptions().hourCycle);
assertEquals("00:00", df_23_t.formatRange(midnight, midnight));
assertEquals("12:00" ,df_23_t.formatRange(noon, noon));

let df_23_dt = new Intl.DateTimeFormat(
    "en", {timeStyle: "short", dateStyle: "short", hourCycle: "h23"})
assertEquals("h23", df_23_dt.resolvedOptions().hourCycle);
assertEquals("4/4/19, 00:00", df_23_dt.formatRange(midnight, midnight));
assertEquals("4/4/19, 12:00" ,df_23_dt.formatRange(noon, noon));

let df_24 = new Intl.DateTimeFormat(
    "en", {hour: "numeric", minute: "numeric", hourCycle: "h24"})
assertEquals("h24", df_24.resolvedOptions().hourCycle);
assertEquals("24:00", df_24.formatRange(midnight, midnight));
assertEquals("12:00", df_24.formatRange(noon, noon));

let df_24_t = new Intl.DateTimeFormat(
    "en", {timeStyle: "short", hourCycle: "h24"})
assertEquals("h24", df_24_t.resolvedOptions().hourCycle);
assertEquals("24:00", df_24_t.formatRange(midnight, midnight));
assertEquals("12:00", df_24_t.formatRange(noon, noon));

let df_24_dt = new Intl.DateTimeFormat(
    "en", {timeStyle: "short", dateStyle: "short", hourCycle: "h24"})
assertEquals("h24", df_24_dt.resolvedOptions().hourCycle);
assertEquals("4/4/19, 24:00", df_24_dt.formatRange(midnight, midnight));
assertEquals("4/4/19, 12:00", df_24_dt.formatRange(noon, noon));

let df_11_ja = new Intl.DateTimeFormat(
    "ja-JP", {hour: "numeric", minute: "numeric", hourCycle: "h11"})
assertEquals("h11", df_11_ja.resolvedOptions().hourCycle);
assertEquals("午前0:00", df_11_ja.formatRange(midnight, midnight));
assertEquals("午後0:00", df_11_ja.formatRange(noon, noon));

let df_11_ja_t = new Intl.DateTimeFormat(
    "ja-JP", {timeStyle: "short", hourCycle: "h11"})
assertEquals("h11", df_11_ja_t.resolvedOptions().hourCycle);
assertEquals("午前0:00", df_11_ja_t.formatRange(midnight, midnight));
assertEquals("午後0:00", df_11_ja_t.formatRange(noon, noon));

let df_11_ja_dt = new Intl.DateTimeFormat(
    "ja-JP", {timeStyle: "short", dateStyle: "short", hourCycle: "h11"})
assertEquals("h11", df_11_ja_dt.resolvedOptions().hourCycle);
assertEquals("2019/04/04 午前0:00", df_11_ja_dt.formatRange(midnight, midnight));
assertEquals("2019/04/04 午後0:00", df_11_ja_dt.formatRange(noon, noon));

let df_12_ja = new Intl.DateTimeFormat(
    "ja-JP", {hour: "numeric", minute: "numeric", hourCycle: "h12"})
assertEquals("h12", df_12_ja.resolvedOptions().hourCycle);
assertEquals("午前12:00", df_12_ja.formatRange(midnight, midnight));
assertEquals("午後12:00", df_12_ja.formatRange(noon, noon));

let df_12_ja_t = new Intl.DateTimeFormat(
    "ja-JP", {timeStyle: "short", hourCycle: "h12"})
assertEquals("h12", df_12_ja_t.resolvedOptions().hourCycle);
assertEquals("午前12:00", df_12_ja_t.formatRange(midnight, midnight));
assertEquals("午後12:00", df_12_ja_t.formatRange(noon, noon));

let df_12_ja_dt = new Intl.DateTimeFormat(
    "ja-JP", {timeStyle: "short", dateStyle: "short", hourCycle: "h12"})
assertEquals("h12", df_12_ja_dt.resolvedOptions().hourCycle);
assertEquals("2019/04/04 午前12:00", df_12_ja_dt.formatRange(midnight, midnight));
assertEquals("2019/04/04 午後12:00", df_12_ja_dt.formatRange(noon, noon));

let df_23_ja = new Intl.DateTimeFormat(
    "ja-JP", {hour: "numeric", minute: "numeric", hourCycle: "h23"})
assertEquals("h23", df_23_ja.resolvedOptions().hourCycle);
assertEquals("0:00", df_23_ja.formatRange(midnight, midnight));
assertEquals("12:00", df_23_ja.formatRange(noon, noon));

let df_23_ja_t = new Intl.DateTimeFormat(
    "ja-JP", {timeStyle: "short", hourCycle: "h23"})
assertEquals("h23", df_23_ja_t.resolvedOptions().hourCycle);
assertEquals("0:00", df_23_ja_t.formatRange(midnight, midnight));
assertEquals("12:00", df_23_ja_t.formatRange(noon, noon));

let df_23_ja_dt = new Intl.DateTimeFormat(
    "ja-JP", {timeStyle: "short", dateStyle: "short", hourCycle: "h23"})
assertEquals("h23", df_23_ja_dt.resolvedOptions().hourCycle);
assertEquals("2019/04/04 0:00", df_23_ja_dt.formatRange(midnight, midnight));
assertEquals("2019/04/04 12:00", df_23_ja_dt.formatRange(noon, noon));

let df_24_ja = new Intl.DateTimeFormat(
    "ja-JP", {hour: "numeric", minute: "numeric", hourCycle: "h24"})
assertEquals("h24", df_24_ja.resolvedOptions().hourCycle);
assertEquals("24:00", df_24_ja.formatRange(midnight, midnight));
assertEquals("12:00", df_24_ja.formatRange(noon, noon));

let df_24_ja_t = new Intl.DateTimeFormat(
    "ja-JP", {timeStyle: "short", hourCycle: "h24"})
assertEquals("h24", df_24_ja_t.resolvedOptions().hourCycle);
assertEquals("24:00", df_24_ja_t.formatRange(midnight, midnight));
assertEquals("12:00", df_24_ja_t.formatRange(noon, noon));

let df_24_ja_dt = new Intl.DateTimeFormat(
    "ja-JP", {timeStyle: "short", dateStyle: "short", hourCycle: "h24"})
assertEquals("h24", df_24_ja_dt.resolvedOptions().hourCycle);
assertEquals("2019/04/04 24:00", df_24_ja_dt.formatRange(midnight, midnight));
assertEquals("2019/04/04 12:00", df_24_ja_dt.formatRange(noon, noon));