Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f94f80

Browse files
authored
OBPIH-7556 Screen goes blank after adding row with exp date in cycle count in es_mx locale (#5584)
1 parent1263553 commit1f94f80

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

‎src/js/components/form-elements/v2/DateField.jsx‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,28 @@ const DateField = ({
4747
}
4848
onChange(date?.format(DateFormat.MMM_DD_YYYY));
4949
};
50-
const{ locale}=useSelector((state)=>({
51-
locale:getCurrentLocale(state),
52-
}));
50+
constlocale=useSelector(getCurrentLocale);
5351

5452
constformatDate=(dateToFormat)=>{
5553
if(!dateToFormat){
5654
returnnull;
5755
}
58-
if(showTimeSelect){
59-
returnmoment(newDate(dateToFormat),DateFormat.MMM_DD_YYYY_HH_MM_SS);
56+
57+
constformat=showTimeSelect
58+
?DateFormat.MMM_DD_YYYY_HH_MM_SS
59+
:DateFormat.MMM_DD_YYYY;
60+
61+
// The locale has to be lower cased, because moment.js accepts arguments like: 'es-mx', not
62+
// 'es-MX' we can't just return null if the locale is not already loaded, because the date needs
63+
// to have value, so we default to 'en' in that case
64+
constlanguage=(locale||'en').toLowerCase();
65+
// If the date is not valid in the given format, we try to parse it without format
66+
constdate=moment(dateToFormat,format,language,true);
67+
if(date.isValid()){
68+
returndate;
6069
}
61-
returnshowTimeSelect
62-
?moment(newDate(dateToFormat),DateFormat.MMM_DD_YYYY_HH_MM_SS)
63-
:moment(newDate(dateToFormat),DateFormat.MMM_DD_YYYY);
70+
// Fallback to default parsing
71+
returnmoment(dateToFormat);
6472
};
6573

6674
constselectedDate=formatDate(value);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp