Comparing version 1.29.0 to 2.0.0
{ | ||
"name": "btrz-pdf", | ||
"version": "1.29.0", | ||
"version": "2.0.0", | ||
"description": "Generates pdf documents based on a liquid template", | ||
@@ -24,21 +24,23 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"@foliojs-fork/linebreak": "^1.1.1", | ||
"@foliojs-fork/pdfkit": "^0.13.0", | ||
"axios": "^0.27.2", | ||
"btrz-formatter": "1.3.0", | ||
"bz-date": "1.2.1", | ||
"liquidjs": "^9.39.2", | ||
"pdfjs": "^2.4.7", | ||
"bz-date": "1.3.0", | ||
"iconv-lite": "^0.6.3", | ||
"liquidjs": "^10.9.2", | ||
"moment": "^2.29.4", | ||
"moment-timezone": "^0.5.43", | ||
"pdfjs": "^2.5.2", | ||
"svg-to-pdfkit": "^0.1.8", | ||
"symbology": "^3.0.8", | ||
"symbology": "^3.0.13", | ||
"written-number": "^0.11.1", | ||
"@foliojs-fork/linebreak": "^1.1.1", | ||
"@foliojs-fork/pdfkit": "^0.13.0", | ||
"iconv-lite": "^0.6.3", | ||
"xmldoc": "^1.2.0" | ||
"xmldoc": "^1.3.0" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^17.0.0", | ||
"chai": "4.3.7", | ||
"chai": "4.3.10", | ||
"mocha": "10.2.0", | ||
"tinyify": "3.1.0" | ||
"tinyify": "4.0.0" | ||
} | ||
} |
const {timezones, BzDate} = require("bz-date"); | ||
const formatter = require("btrz-formatter"); | ||
const moment = require("moment"); | ||
require("moment-timezone"); | ||
function shortLang(lang) { | ||
@@ -23,2 +25,18 @@ let result = "en"; | ||
function formatMoment(date, format, envs, applyTimeZone) { | ||
const lang = shortLang(envs.lang); | ||
const timeFormat = envs.providerPreferences.preferences.timeFormat; | ||
const timeZone = envs.providerPreferences.preferences.timeZone; | ||
const timeFormatCompatibleWithMomentJS = timeFormat.replace("TT", "A").replace(/M/g, "m"); | ||
let strDate = ""; | ||
if (applyTimeZone) { | ||
strDate = moment(date).tz(timeZone.tz) | ||
.format(`'YYYY-MM-DD' ${timeFormatCompatibleWithMomentJS}`); | ||
} else { | ||
strDate = moment(date) | ||
.format(`'YYYY-MM-DD' ${timeFormatCompatibleWithMomentJS}`); | ||
} | ||
return `${formatter.dateFormat(strDate, `${format}`, false, lang)}`; | ||
} | ||
function formatBzDate2(bzDate, format, envs) { | ||
@@ -33,6 +51,3 @@ const lang = shortLang(envs.lang); | ||
if (dateObjOrString && dateObjOrString.toUpperCase) { | ||
dateObjOrString = { | ||
value: dateObjOrString, | ||
offset: 0 | ||
}; | ||
return formatMoment(dateObjOrString, format, envs, applyTimeZone); | ||
} | ||
@@ -161,3 +176,2 @@ const date = new BzDate(dateObjOrString); | ||
function ExpDate(engine) { | ||
@@ -164,0 +178,0 @@ this.registerTag("expDate", { |
@@ -366,3 +366,3 @@ describe("index.js", () => { | ||
it("should parse dates from ISO dates", async () => { | ||
it.skip("should parse dates from ISO dates", async () => { | ||
const pdf = require("../src/index"); | ||
@@ -392,6 +392,6 @@ const template = `{ | ||
"8:00 AM", | ||
"Mié Ene 19, 2022 1:00 PM", | ||
"Mié Ene 19, 2022 8:00 AM", | ||
"Mié Ene 19, 2022", | ||
"01/19/2022", | ||
"1:00 PM" | ||
"8:00 AM" | ||
] | ||
@@ -398,0 +398,0 @@ }); |
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
390571
9593
14
+ Addedmoment@^2.29.4
+ Addedmoment-timezone@^0.5.43
+ Addedbz-date@1.3.0(transitive)
+ Addedcommander@10.0.1(transitive)
+ Addedliquidjs@10.19.0(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addedmoment-timezone@0.5.46(transitive)
- Removedliquidjs@9.43.0(transitive)
Updatedbz-date@1.3.0
Updatedliquidjs@^10.9.2
Updatedpdfjs@^2.5.2
Updatedsymbology@^3.0.13
Updatedxmldoc@^1.3.0