mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-07 09:23:00 +02:00
#144 - Fix date value issue
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
- Rendered more hooks than during the previous render in `FileList`
|
||||
- [#142](https://github.com/estruyf/vscode-front-matter/issues/142): Fix for unknown tags where it throws an error
|
||||
- [#143](https://github.com/estruyf/vscode-front-matter/issues/143): Fix for duplicate values in the file list
|
||||
- [#144](https://github.com/estruyf/vscode-front-matter/issues/144): Fix for `toISOString` does not exist on object
|
||||
|
||||
## [5.0.0] - 2021-10-07 - [Release Notes](https://beta.frontmatter.codes/updates/v5.0.0)
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ export class Article {
|
||||
if (dateFormat && typeof dateFormat === "string") {
|
||||
return format(dateValue, dateFormat);
|
||||
} else {
|
||||
return dateValue.toISOString();
|
||||
return typeof dateValue.toISOString === 'function' ? dateValue.toISOString() : dateValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,10 @@ export const DateTimeField: React.FunctionComponent<IDateTimeFieldProps> = ({lab
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
if (dateValue?.toISOString() !== date?.toISOString()) {
|
||||
const crntValue = typeof date?.toISOString === 'function' ? date.toISOString() : date;
|
||||
const stateValue = typeof dateValue?.toISOString === 'function' ? dateValue.toISOString() : dateValue;
|
||||
|
||||
if (crntValue !== stateValue) {
|
||||
setDateValue(date);
|
||||
}
|
||||
}, [ date ]);
|
||||
@@ -45,7 +48,7 @@ export const DateTimeField: React.FunctionComponent<IDateTimeFieldProps> = ({lab
|
||||
|
||||
<div className={`metadata_field__datetime`}>
|
||||
<DatePicker
|
||||
selected={dateValue as Date}
|
||||
selected={dateValue as Date || null}
|
||||
onChange={onDateChange}
|
||||
timeInputLabel="Time:"
|
||||
dateFormat={format || "MM/dd/yyyy HH:mm"}
|
||||
|
||||
Reference in New Issue
Block a user