Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
feat(Date): Format eLife's publication date correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcmoulton committed Mar 5, 2020
1 parent 672b7ce commit d0603a2
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/themes/elife/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
export {}
import { first, ready } from '../../util'
import DateTimeFormat = Intl.DateTimeFormat

function elifeFormatDate(date: Date): string {
const formatter: DateTimeFormat = new Intl.DateTimeFormat('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric'
})
return formatter.format(date)
}

ready(() => {
const dateEl: Element | null = first(':--Date')
if (!(dateEl instanceof Element)) return
const date = new Date(dateEl.innerHTML)
const formattedDate: string = elifeFormatDate(date)
dateEl.innerHTML = formattedDate
})

0 comments on commit d0603a2

Please sign in to comment.