-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1883 from blockchain-certificates/feat/show-expir…
…ation-date feat(Expiration): show expiration date in error message
- Loading branch information
Showing
6 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import getText from './getText'; | ||
|
||
function replaceMonth (pattern: string, monthIndex: number): string { | ||
const months = getText('date', 'months'); | ||
return pattern.replace('MM', months[monthIndex]); | ||
} | ||
|
||
function replaceDay (pattern: string, day: string): string { | ||
return pattern.replace('DD', day); | ||
} | ||
|
||
function replaceYear (pattern: string, year: string): string { | ||
return pattern.replace('YYYY', year); | ||
} | ||
|
||
export default function getDateFormat (date: string): string { | ||
const pattern = getText('date', 'pattern'); | ||
if (date.slice(-1) === 'Z') { | ||
date = date.slice(0, date.length - 1); | ||
} else if (date.includes('+')) { | ||
date = date.split('+')[0]; | ||
} | ||
const objDate = new Date(date); | ||
|
||
let formattedDate = replaceMonth(pattern, objDate.getMonth()); | ||
formattedDate = replaceDay(formattedDate, objDate.getDate().toString(10)); | ||
formattedDate = replaceYear(formattedDate, objDate.getFullYear().toString(10)); | ||
return formattedDate; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters