@@ -32,7 +32,11 @@ const testSuite = goog.require('goog.testing.testSuite');
3232
3333const { DayPeriods_zh_Hant, setDayPeriods} = goog . require ( 'goog.i18n.DayPeriods' ) ;
3434
35- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_en ) ;
35+ const DATETIMESYMBOLS =
36+ goog . reflect . objectProperty ( 'DateTimeSymbols' , goog . i18n ) ;
37+ const LOCALE = goog . reflect . objectProperty ( 'LOCALE' , goog ) ;
38+
39+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_en ) ;
3640
3741/**
3842 * @record
@@ -141,12 +145,12 @@ testSuite({
141145 setUpPage ( ) { } ,
142146
143147 setUp ( ) {
144- replacer . replace ( goog , ' LOCALE' , 'en' ) ;
145- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_en ) ;
148+ replacer . replace ( goog , LOCALE , 'en' ) ;
149+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_en ) ;
146150 } ,
147151
148152 tearDown ( ) {
149- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_en ) ;
153+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_en ) ;
150154 } ,
151155
152156 testNegativeYear ( ) {
@@ -489,7 +493,7 @@ testSuite({
489493 } ,
490494
491495 testChineseDate ( ) {
492- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_zh ) ;
496+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_zh ) ;
493497
494498 // JavaScript month start from 0, July is 7 - 1
495499 const date = new Date ( 2006 , 7 - 1 , 24 , 12 , 12 , 12 , 0 ) ;
@@ -531,7 +535,8 @@ testSuite({
531535 } ,
532536
533537 testZhTwBFormat ( ) {
534- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_zh_TW ) ;
538+ let nativeMode = true ;
539+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_zh_TW ) ;
535540
536541 // Make sure we have the day period info.
537542 setDayPeriods ( DayPeriods_zh_Hant ) ;
@@ -544,7 +549,10 @@ testSuite({
544549 let date = new Date ( 2006 , 7 - 1 , 24 , 12 , 12 , 12 , 0 ) ;
545550
546551 let parsedDate = parser . parse ( gmtDateStringPm , date ) ;
547- assertTrue ( 'parsedDate=' + parsedDate , parsedDate > 0 ) ;
552+
553+ assertTrue (
554+ 'nativeMode=' + nativeMode + ', parsedDate=' + parsedDate ,
555+ parsedDate > 0 ) ;
548556 // This should be give 10PM == 22:00.
549557 const normalizedHourPm =
550558 ( 24 + date . getHours ( ) + date . getTimezoneOffset ( ) / 60 ) % 24 ;
@@ -556,7 +564,7 @@ testSuite({
556564 // for parsing dates with such native digits.
557565 testDatesWithNativeDigits ( ) {
558566 // Language Arabic is one example with
559- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_fa ) ;
567+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_fa ) ;
560568
561569 let formatter = new DateTimeFormat ( DateTimeFormat . Format . FULL_DATE ) ;
562570 let parser = new DateTimeParse ( DateTimeFormat . Format . FULL_DATE ) ;
@@ -679,7 +687,7 @@ testSuite({
679687 } ,
680688
681689 testFrenchShortQuarter ( ) {
682- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_fr ) ;
690+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_fr ) ;
683691 const parser = new DateTimeParse ( 'yyyyQQ' ) ;
684692
685693 assertParsedDateEquals ( 2009 , 7 - 1 , 1 , parser , '2009T3' ) ;
@@ -769,7 +777,7 @@ testSuite({
769777
770778 /** @bug 9901750 */
771779 testStandaloneMonthPattern ( ) {
772- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_pl ) ;
780+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_pl ) ;
773781 const date1 = new GoogDate ( 2006 , 7 - 1 ) ;
774782 const date2 = new GoogDate ( ) ;
775783 const formatter = new DateTimeFormat ( 'LLLL yyyy' ) ;
@@ -784,7 +792,7 @@ testSuite({
784792 const symbols = [ DateTimeSymbols_en , DateTimeSymbols_pl ] ;
785793
786794 for ( let i = 0 ; i < symbols . length ; i ++ ) {
787- replacer . replace ( goog . i18n , 'DateTimeSymbols' , symbols [ i ] ) ;
795+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , symbols [ i ] ) ;
788796 const dateTimeSymbols = symbols [ i ] ;
789797 const tests = {
790798 'MMMM yyyy' : dateTimeSymbols . MONTHS ,
@@ -827,7 +835,7 @@ testSuite({
827835
828836 testQuotedPattern ( ) {
829837 // Regression test for b/29990921.
830- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_en ) ;
838+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_en ) ;
831839
832840 // Literal apostrophe
833841 let parser = new DateTimeParse ( 'MMM \'\'yy' ) ;
@@ -879,8 +887,8 @@ testSuite({
879887 testZhHantTwDayPeriods ( ) {
880888 // b/208532468, 3-Dec-2021
881889
882- replacer . replace ( goog , ' LOCALE' , 'zh-TW' ) ;
883- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_zh_TW ) ;
890+ replacer . replace ( goog , LOCALE , 'zh-TW' ) ;
891+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_zh_TW ) ;
884892 // Set up for parts of the day in Chinese.
885893 setDayPeriods ( DayPeriods_zh_Hant ) ;
886894
@@ -943,8 +951,8 @@ testSuite({
943951 testRoundTripZhTw ( ) {
944952 // Test for b/208532468 round trip with zh_TW with flexible time periods
945953 const date = new Date ( 0 , 0 , 0 , 17 ) ;
946- replacer . replace ( goog , ' LOCALE' , 'zh-TW' ) ;
947- replacer . replace ( goog . i18n , 'DateTimeSymbols' , DateTimeSymbols_zh_TW ) ;
954+ replacer . replace ( goog , LOCALE , 'zh-TW' ) ;
955+ replacer . replace ( goog . i18n , DATETIMESYMBOLS , DateTimeSymbols_zh_TW ) ;
948956
949957 setDayPeriods ( DayPeriods_zh_Hant ) ;
950958
0 commit comments