Update index.mjs

This commit is contained in:
lowlighter
2021-03-12 12:16:44 +01:00
parent 8db237cb84
commit 415fd88bf4

View File

@@ -81,6 +81,7 @@
const diff = (Date.now()-(new Date(data.user.createdAt)).getTime())/(365*24*60*60*1000) const diff = (Date.now()-(new Date(data.user.createdAt)).getTime())/(365*24*60*60*1000)
const years = Math.floor(diff) const years = Math.floor(diff)
const months = Math.floor((diff-years)*12) const months = Math.floor((diff-years)*12)
computed.registered = {years, months, diff}
computed.registration = years ? `${years} year${imports.s(years)} ago` : months ? `${months} month${imports.s(months)} ago` : `${Math.ceil(diff*365)} day${imports.s(Math.ceil(diff*365))} ago` computed.registration = years ? `${years} year${imports.s(years)} ago` : months ? `${months} month${imports.s(months)} ago` : `${Math.ceil(diff*365)} day${imports.s(Math.ceil(diff*365))} ago`
computed.cakeday = years > 1 ? [new Date(), new Date(data.user.createdAt)].map(date => date.toISOString().match(/(?<mmdd>\d{2}-\d{2})(?=T)/)?.groups?.mmdd).every((v, _, a) => v === a[0]) : false computed.cakeday = years > 1 ? [new Date(), new Date(data.user.createdAt)].map(date => date.toISOString().match(/(?<mmdd>\d{2}-\d{2})(?=T)/)?.groups?.mmdd).every((v, _, a) => v === a[0]) : false