Skip to content

Commit

Permalink
Correctly parse date strings
Browse files Browse the repository at this point in the history
  • Loading branch information
bcomnes committed Sep 14, 2023
1 parent effd6e8 commit be98e4d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion relative-time/index.js
Expand Up @@ -451,7 +451,10 @@ export class TonicRelativeTime extends Tonic {
const locale = this.props.locale || localeFromElement(this)

if (typeof date === 'string') {
date = this.props.date = new Date(+this.props.date)
date = this.props.date =
/^\d+$/.test(this.props.date)
? new Date(+this.props.date)
: new Date(this.props.date)
}

if (typeof date === 'number') {
Expand Down

0 comments on commit be98e4d

Please sign in to comment.