Skip to content

Commit

Permalink
Merge pull request #7 from docknetwork/feat/expose-dates
Browse files Browse the repository at this point in the history
Expose dates
  • Loading branch information
cykoder authored Apr 11, 2022
2 parents 3e2cd3e + 1e70bf0 commit 38913f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@docknetwork/prettyvc",
"description": "Render pretty verifiable credentials",
"version": "1.1.4",
"version": "1.1.5",
"main": "lib/index.js",
"license": "MIT",
"repository": {
Expand Down
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ export async function getVCData(credential, options = {}) {
const issuerName = getIssuerName(credential, didMap);
const images = getCredentialImage(credential, generateImages);
const issuanceDate = new Date(credential.issuanceDate);
const expirationDate = credential.expirationDate && new Date(credential.expirationDate);
const formatter = new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
const date = formatter.format(issuanceDate);
const expirationDateStr = expirationDate ? formatter.format(expirationDate) : '';
const qrImage = generateQR && (await generateQRImage(credential, qrUrl));

const template = options.template || guessCredentialTemplate(credential, options.typeToTemplateMap || {});
Expand All @@ -244,6 +246,12 @@ export async function getVCData(credential, options = {}) {
attributes,
subjects,
issuer: credential.issuer,

// Dates
issuanceDate,
expirationDate,
expirationDateStr,
dateStr: date,
};
}

Expand Down

0 comments on commit 38913f5

Please sign in to comment.