fix: handle sec & ms timestamps properly (#702)

pull/703/head
Austin 2 years ago committed by GitHub
parent ab401822aa
commit 635fcf6356
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -51,9 +51,12 @@ export default function cleanDatePublished(
{ timezone, format } = {}
) {
// If string is in milliseconds or seconds, convert to int and return
if (MS_DATE_STRING.test(dateString) || SEC_DATE_STRING.test(dateString)) {
if (MS_DATE_STRING.test(dateString)) {
return new Date(parseInt(dateString, 10)).toISOString();
}
if (SEC_DATE_STRING.test(dateString)) {
return new Date(parseInt(dateString, 10) * 1000).toISOString();
}
let date = createDate(dateString, timezone, format);

Loading…
Cancel
Save