Skip to content

Commit

Permalink
fix: handle sec & ms timestamps properly (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinmbrown authored Oct 24, 2022
1 parent ab40182 commit 635fcf6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cleaners/date-published.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 635fcf6

Please sign in to comment.