Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid bugs with native Date class #12098

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parseISO, format } from 'date-fns'

export default function Date({ dateString }) {
export default function DateFormater({ dateString }) {
const date = parseISO(dateString)
return <time dateTime={dateString}>{format(date, 'LLLL d, yyyy')}</time>
}
4 changes: 2 additions & 2 deletions examples/blog-starter/components/hero-post.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Avatar from '../components/avatar'
import Date from '../components/date'
import DateFormater from '../components/date-formater'
import CoverImage from '../components/cover-image'
import Link from 'next/link'

Expand All @@ -24,7 +24,7 @@ export default function HeroPost({
</Link>
</h3>
<div className="mb-4 md:mb-0 text-lg">
<Date dateString={date} />
<DateFormater dateString={date} />
</div>
</div>
<div>
Expand Down
4 changes: 2 additions & 2 deletions examples/blog-starter/components/post-header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Avatar from '../components/avatar'
import Date from '../components/date'
import DateFormater from '../components/date-formater'
import CoverImage from '../components/cover-image'
import PostTitle from '../components/post-title'

Expand All @@ -18,7 +18,7 @@ export default function PostHeader({ title, coverImage, date, author }) {
<Avatar name={author.name} picture={author.picture} />
</div>
<div className="mb-6 text-lg">
<Date dateString={date} />
<DateFormater dateString={date} />
</div>
</div>
</>
Expand Down
4 changes: 2 additions & 2 deletions examples/blog-starter/components/post-preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Avatar from '../components/avatar'
import Date from '../components/date'
import DateFormater from '../components/date-formater'
import CoverImage from './cover-image'
import Link from 'next/link'

Expand All @@ -22,7 +22,7 @@ export default function PostPreview({
</Link>
</h3>
<div className="text-lg mb-4">
<Date dateString={date} />
<DateFormater dateString={date} />
</div>
<p className="text-lg leading-relaxed mb-4">{excerpt}</p>
<Avatar name={author.name} picture={author.picture} />
Expand Down