Skip to content

Commit

Permalink
Move makeLastUpdatedFriendly into parse-date
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatGuySam committed Mar 7, 2021
1 parent b4f2be4 commit 86f61b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 11 additions & 0 deletions helpers/parse-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ const getRelativeTime = function (d1, d2 = new Date()) {

}

export function makeLastUpdatedFriendly ( lastUpdated ) {

if ( !lastUpdated ) return null

const options = { month: "long", day: "numeric", year: "numeric" }
const date = new Date( lastUpdated.raw )
const americanDate = new Intl.DateTimeFormat("en-US", options).format(date)

return americanDate
}

export default function (rawDate) {

const date = new Date(rawDate)
Expand Down
11 changes: 2 additions & 9 deletions pages/app/_slug/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</template>

<script>
import parseDate from '~/helpers/parse-date'
import { lastUpdatedFriendly } from '~/helpers/parse-date'
import { getAppEndpoint } from '~/helpers/app-derived.js'
import LinkButton from '~/components/link-button.vue'
Expand Down Expand Up @@ -105,14 +105,7 @@ export default {
},
computed: {
lastUpdatedFriendly () {
if (this.app.lastUpdated === null) return
const options = { month: "long", day: "numeric", year: "numeric" }
const date = new Date(this.app.lastUpdated.raw)
const americanDate = new Intl.DateTimeFormat("en-US", options).format(date)
return americanDate
return lastUpdatedFriendly( this.app.lastUpdated )
}
},
head() {
Expand Down

0 comments on commit 86f61b1

Please sign in to comment.