@@ -581,75 +581,50 @@ public void ctorDouble() {
581581
582582 @ Test
583583 public void toLocaleEnUs () {
584- // real browser toLocale("12/18/2021, 10:23:00 PM", "new
585- // Date('2021-12-18T22:23').toLocaleString('en-US')");
586- // toLocale("12/18/21 10:23 PM", "new Date('2021-12-18T22:23').toLocaleString('en-US')");
587- toLocale ("12/18/21, 10:23 PM" , "new Date('2021-12-18T22:23').toLocaleString('en-US')" );
588-
589- // real browser toLocale("12/18/2021", "new
590- // Date('2021-12-18T22:23').toLocaleDateString('en-US')");
591- toLocale ("12/18/21" , "new Date('2021-12-18T22:23').toLocaleDateString('en-US')" );
592-
593- // real browser toLocale("10:23:00 PM", "new
594- // Date('2021-12-18T22:23').toLocaleTimeString('en-US')");
595- toLocale ("10:23 PM" , "new Date('2021-12-18T22:23').toLocaleTimeString('en-US')" );
584+ toLocale ("12/18/2021, 10:23:00 PM" , "new Date('2021-12-18T22:23').toLocaleString('en-US')" );
585+ toLocale ("12/18/2021" , "new Date('2021-12-18T22:23').toLocaleDateString('en-US')" );
586+ toLocale ("10:23:00 PM" , "new Date('2021-12-18T22:23').toLocaleTimeString('en-US')" );
596587 }
597588
598589 @ Test
599590 public void toLocaleDeDe () {
600- // real browser toLocale("18.12.2021, 22:23:00", "new
601- // Date('2021-12-18T22:23').toLocaleString('de-DE')");
602- // toLocale("18.12.21 22:23", "new Date('2021-12-18T22:23').toLocaleString('de-DE')");
603- toLocale ("18.12.21, 22:23" , "new Date('2021-12-18T22:23').toLocaleString('de-DE')" );
604-
605- // real browser toLocale("18.12.2021", "new
606- // Date('2021-12-18T22:23').toLocaleDateString('de-DE')");
607- toLocale ("18.12.21" , "new Date('2021-12-18T22:23').toLocaleDateString('de-DE')" );
608-
609- // real browser toLocale("22:23:00", "new
610- // Date('2021-12-18T22:23').toLocaleTimeString('de-DE')");
611- toLocale ("22:23" , "new Date('2021-12-18T22:23').toLocaleTimeString('de-DE')" );
591+ toLocale ("18.12.2021, 22:23:00" , "new Date('2021-12-18T22:23').toLocaleString('de-DE')" );
592+ toLocale ("18.12.2021" , "new Date('2021-12-18T22:23').toLocaleDateString('de-DE')" );
593+ toLocale ("22:23:00" , "new Date('2021-12-18T22:23').toLocaleTimeString('de-DE')" );
612594 }
613595
614596 @ Test
615597 public void toLocaleJaJp () {
616- // real browser toLocale("2021/12/18 22:23:00", "new
617- // Date('2021-12-18T22:23').toLocaleString('ja-JP')");
618- // toLocale("21/12/18 22:23", "new Date('2021-12-18T22:23').toLocaleString('ja-JP')");
619- toLocale ("2021/12/18 22:23" , "new Date('2021-12-18T22:23').toLocaleString('ja-JP')" );
620-
621- // real browser toLocale("2021/12/18", "new
622- // Date('2021-12-18T22:23').toLocaleDateString('ja-JP')");
623- // toLocale("21/12/18", "new Date('2021-12-18T22:23').toLocaleDateString('ja-JP')");
598+ toLocale ("2021/12/18 22:23:00" , "new Date('2021-12-18T22:23').toLocaleString('ja-JP')" );
624599 toLocale ("2021/12/18" , "new Date('2021-12-18T22:23').toLocaleDateString('ja-JP')" );
600+ toLocale ("22:23:00" , "new Date('2021-12-18T22:23').toLocaleTimeString('ja-JP')" );
601+ }
625602
626- // real browser toLocale("22:23:00", "new
627- // Date('2021-12-18T22:23').toLocaleTimeString('ja-JP')");
628- toLocale ("22:23" , "new Date('2021-12-18T22:23').toLocaleTimeString('ja-JP')" );
603+ @ Test
604+ public void toLocaleFrFr () {
605+ toLocale ("18/12/2021 22:23:00" , "new Date('2021-12-18T22:23').toLocaleString('fr-FR')" );
606+ toLocale ("18/12/2021" , "new Date('2021-12-18T22:23').toLocaleDateString('fr-FR')" );
607+ toLocale ("22:23:00" , "new Date('2021-12-18T22:23').toLocaleTimeString('fr-FR')" );
608+ }
609+
610+ @ Test
611+ public void toLocaleFiFi () {
612+ // real browser: "18.12.2021 klo 22.23.00" (includes "klo" between date and time)
613+ toLocale ("18.12.2021 22.23.00" , "new Date('2021-12-18T22:23').toLocaleString('fi-FI')" );
614+ toLocale ("18.12.2021" , "new Date('2021-12-18T22:23').toLocaleDateString('fi-FI')" );
615+ toLocale ("22.23.00" , "new Date('2021-12-18T22:23').toLocaleTimeString('fi-FI')" );
629616 }
630617
631618 @ Test
632619 public void toLocaleArray () {
633- // real browser toLocale("2021/12/18 22:23:00", "new
634- // Date('2021-12-18T22:23').toLocaleString(['foo', 'ja-JP', 'en-US'])");
635- // toLocale("21/12/18 22:23", "new Date('2021-12-18T22:23').toLocaleString(['foo', 'ja-JP',
636- // 'en-US'])");
637620 toLocale (
638- "2021/12/18 22:23" ,
621+ "2021/12/18 22:23:00 " ,
639622 "new Date('2021-12-18T22:23').toLocaleString(['foo', 'ja-JP', 'en-US'])" );
640-
641- // real browser toLocale("2021/12/18", "new
642- // Date('2021-12-18T22:23').toLocaleDateString(['foo', 'ja-JP', 'en-US'])");
643- // toLocale("21/12/18", "new Date('2021-12-18T22:23').toLocaleDateString(['foo', 'ja-JP',
644- // 'en-US'])");
645623 toLocale (
646624 "2021/12/18" ,
647625 "new Date('2021-12-18T22:23').toLocaleDateString(['foo', 'ja-JP', 'en-US'])" );
648-
649- // real browser toLocale("22:23:00", "new
650- // Date('2021-12-18T22:23').toLocaleTimeString(['foo', 'ja-JP', 'en-US'])");
651626 toLocale (
652- "22:23" ,
627+ "22:23:00 " ,
653628 "new Date('2021-12-18T22:23').toLocaleTimeString(['foo', 'ja-JP', 'en-US'])" );
654629 }
655630
@@ -666,6 +641,29 @@ private static void toLocale(final String expected, final String js) {
666641 });
667642 }
668643
644+ @ Test
645+ public void toLocaleEpochDate () {
646+ toLocale ("1/1/1970, 12:00:00 AM" , "new Date(0).toLocaleString('en-US')" );
647+ // real browser: "1.1.1970, 00:00:00" (without zero-padding)
648+ toLocale ("01.01.1970, 00:00:00" , "new Date(0).toLocaleString('de-DE')" );
649+ // real browser: "1970/1/1 0:00:00" (without zero-padding)
650+ toLocale ("1970/01/01 0:00:00" , "new Date(0).toLocaleString('ja-JP')" );
651+ toLocale ("1/1/1970" , "new Date(0).toLocaleDateString('en-US')" );
652+ // real browser: "1.1.1970" (without zero-padding)
653+ toLocale ("01.01.1970" , "new Date(0).toLocaleDateString('de-DE')" );
654+ toLocale ("12:00:00 AM" , "new Date(0).toLocaleTimeString('en-US')" );
655+ toLocale ("00:00:00" , "new Date(0).toLocaleTimeString('de-DE')" );
656+ }
657+
658+ @ Test
659+ public void toLocaleWithSeconds () {
660+ toLocale (
661+ "12/18/2021, 10:23:45 PM" ,
662+ "new Date('2021-12-18T22:23:45').toLocaleString('en-US')" );
663+ toLocale ("10:23:45 PM" , "new Date('2021-12-18T22:23:45').toLocaleTimeString('en-US')" );
664+ toLocale ("22:23:45" , "new Date('2021-12-18T22:23:45').toLocaleTimeString('ja-JP')" );
665+ }
666+
669667 @ Test
670668 public void toDateStringGMT () {
671669 toDateString ("Sat Dec 18 2021" , "GMT" );
0 commit comments