Comparing version 1.8.0 to 1.9.0
{ | ||
"name": "btrz-pdf", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "Generates pdf documents based on a liquid template", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -24,3 +24,10 @@ const {timezones, BzDate} = require("bz-date"); | ||
function getDate(envs, item, propName, format) { | ||
const date = new BzDate(envs[item][propName]); | ||
let dateObjOrString = envs[item][propName]; | ||
if (dateObjOrString && dateObjOrString.toUpperCase) { | ||
dateObjOrString = { | ||
value: dateObjOrString, | ||
offset: 0 | ||
}; | ||
} | ||
const date = new BzDate(dateObjOrString); | ||
return formatBzDate(date, format, envs); | ||
@@ -121,4 +128,3 @@ } | ||
const format = ctx.environments.providerPreferences.preferences.timeFormat; | ||
if (ctx.environments[this.item][this.propName].toUpperCase) { | ||
if (ctx.environments[this.item][this.propName].toUpperCase && ctx.environments[this.item][this.propName].indexOf("T") === -1){ | ||
return getTimeFromString(ctx.environments[this.item][this.propName], format); | ||
@@ -125,0 +131,0 @@ } |
@@ -106,2 +106,3 @@ describe("index.js", () => { | ||
"displayTotalStr3": "289.00", | ||
arrivalTimestamp: "2022-01-19T13:00:00.000Z", | ||
taxes: [], | ||
@@ -279,2 +280,27 @@ ssrs: [ | ||
it("should parse dates from ISO dates", async () => { | ||
const pdf = require("../src/index"); | ||
const template = `{ | ||
"content": [ | ||
"{%- humanDateTime ticket arrivalTimestamp %}", | ||
"{%- humanDate ticket arrivalTimestamp %}", | ||
"{%- dateTime ticket arrivalTimestamp %}", | ||
"{%- dateTime ticket arrivalTimestamp mm/dd/yyyy hh:MM:ss %}", | ||
"{%- dateF ticket arrivalTimestamp %}", | ||
"{%- timeF ticket arrivalTimestamp %}" | ||
] | ||
}`; | ||
const documentDefinition = await pdf.toDocumentDefinition(template, data); | ||
expect(documentDefinition).to.be.eql({ | ||
"content": [ | ||
"Mié Ene 19, 2022 8:00 AM", | ||
"Mié Ene 19, 2022", | ||
"01/19/2022 8:00 AM", | ||
"01/19/2022 08:00:00", | ||
"01/19/2022", | ||
"8:00 AM" | ||
] | ||
}); | ||
}); | ||
it("should return a parsed liquidTemplate", async () => { | ||
@@ -281,0 +307,0 @@ const pdf = require("../src/index"); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57392
1182