@@ -818,6 +818,56 @@ func TestParsingWithUnsupportedLocale(t *testing.T) {
818818 })
819819}
820820
821+ func TestDayPeriodsLayoutCase (t * testing.T ) {
822+ tests := []struct {
823+ name string
824+ format string
825+ value string
826+ lang string
827+ }{
828+ {
829+ name : "AllLowerPm" ,
830+ format : "Monday January 03:04:05pm" ,
831+ value : "lunes enero 03:04:05a.m." ,
832+ lang : LocaleEs ,
833+ },
834+ {
835+ name : "AllUpperPm" ,
836+ format : "Monday January 03:04:05PM" ,
837+ value : "Monday January 03:04:05AM" ,
838+ lang : LocaleEnUS ,
839+ },
840+ {
841+ name : "UpperPmLowerValue" ,
842+ format : "Monday January 03:04:05PM" ,
843+ value : "Monday January 03:04:05am" ,
844+ lang : LocaleEnUS ,
845+ },
846+ {
847+ name : "LowerPmUpperValue" ,
848+ format : "Monday January 03:04:05pm" ,
849+ value : "Monday January 03:04:05AM" ,
850+ lang : LocaleEnUS ,
851+ },
852+ }
853+
854+ for _ , test := range tests {
855+ t .Run (fmt .Sprintf ("ParseWith%s" , test .name ), func (t * testing.T ) {
856+ _ , err := Parse (test .format , test .value , test .lang )
857+ if err != nil {
858+ t .Errorf ("no error expected, got: '%v'" , err )
859+ }
860+ })
861+
862+ t .Run (fmt .Sprintf ("ParseInLocationWith%s" , test .name ), func (t * testing.T ) {
863+ _ , err := ParseInLocation (test .format , test .value , test .lang , defaultLocation )
864+ if err != nil {
865+ t .Errorf ("no error expected, got: '%v'" , err )
866+ }
867+ })
868+ }
869+ }
870+
821871func TestAllLocalesReplacements (t * testing.T ) {
822872 var shortLayoutTests []ParseTest
823873 var longLayoutTests []ParseTest
@@ -826,7 +876,7 @@ func TestAllLocalesReplacements(t *testing.T) {
826876 day := month % 7
827877 period := month % 2
828878
829- shortStdValue := fmt .Sprintf ("%s %s 03:04:05%s" , shortDayNamesStd [day ], shortMonthNamesStd [month ], dayPeriodsStd [period ])
879+ shortStdValue := fmt .Sprintf ("%s %s 03:04:05%s" , shortDayNamesStd [day ], shortMonthNamesStd [month ], dayPeriodsStdUpper [period ])
830880 shortLayoutTests = append (shortLayoutTests , ParseTest {
831881 name : shortStdValue ,
832882 format : "Mon Jan 03:04:05PM" ,
@@ -836,7 +886,7 @@ func TestAllLocalesReplacements(t *testing.T) {
836886 locales : allLocalesTests ("%s %s 03:04:05%s" , []replacement {{shortDayNamesField , day }, {shortMonthNamesField , month }, {dayPeriodsField , period }}),
837887 })
838888
839- longStdValue := fmt .Sprintf ("%s %s 03:04:05%s" , longDayNamesStd [day ], longMonthNamesStd [month ], dayPeriodsStd [period ])
889+ longStdValue := fmt .Sprintf ("%s %s 03:04:05%s" , longDayNamesStd [day ], longMonthNamesStd [month ], dayPeriodsStdUpper [period ])
840890 longLayoutTests = append (longLayoutTests , ParseTest {
841891 format : "Monday January 03:04:05PM" ,
842892 stdValue : longStdValue ,
0 commit comments