Skip to content

Commit

Permalink
add timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
SoYoung210 committed Jan 7, 2025
1 parent 6ee0356 commit c9a37c3
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,36 @@ export const DESCRIPTIONS: { [key: string]: string } = {
DERIVATIVES_RECIPROCAL: "Enforce that derivatives have the same License Terms that you provide them",
NEVER_EXPIRES: "This license never expires",
}

function getTimezoneAbbr(date: Date) {
const longName =
date
.toLocaleDateString("en-US", {
timeZoneName: "long",
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
})
.split(",")[1]
?.trim() || ""

return longName
.split(" ")
.map((word) => word[0])
.join("")
}
const convertExpiration = (expiration: string): string => {
if (expiration == "never" || expiration == "0") {
return DESCRIPTIONS.NEVER_EXPIRES
}

const expirationDateString = new Date(Number(expiration)).toLocaleDateString(undefined, {
const date = new Date(Number(expiration))
const expirationDateString = date.toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
})
return `This license expires in ${expirationDateString}`

const timezone = getTimezoneAbbr(date)

return `This license expires in ${expirationDateString} (${timezone})`
}

const DescribeTerms = (selectedLicenseTerms: PILTerms) => {
Expand Down

0 comments on commit c9a37c3

Please sign in to comment.