bkper 2.5.2 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -571,6 +571,12 @@ export declare class Book {
571
571
  * @returns The date formated
572
572
  */
573
573
  formatDate(date: Date, timeZone?: string): string;
574
+ /**
575
+ * Parse a date string according to date pattern and timezone of the Book.
576
+ *
577
+ * Also parse ISO yyyy-mm-dd format.
578
+ */
579
+ parseDate(date: string): Date;
574
580
  /**
575
581
  * Formats a value according to [[DecimalSeparator]] and fraction digits of the Book.
576
582
  *
package/lib/model/Book.js CHANGED
@@ -333,6 +333,14 @@ class Book {
333
333
  }
334
334
  return Utils.formatDate(date, this.getDatePattern(), timeZone);
335
335
  }
336
+ /**
337
+ * Parse a date string according to date pattern and timezone of the Book.
338
+ *
339
+ * Also parse ISO yyyy-mm-dd format.
340
+ */
341
+ parseDate(date) {
342
+ return Utils.parseDate(date, this.getDatePattern(), this.getTimeZone());
343
+ }
336
344
  /**
337
345
  * Formats a value according to [[DecimalSeparator]] and fraction digits of the Book.
338
346
  *
package/lib/utils.js CHANGED
@@ -127,7 +127,14 @@ function formatDateISO(date, timeZone) {
127
127
  }
128
128
  exports.formatDateISO = formatDateISO;
129
129
  function parseDate(date, pattern, timeZone) {
130
- return luxon_1.DateTime.fromFormat(date, pattern, { zone: timeZone }).toJSDate();
130
+ let dateObject = luxon_1.DateTime.fromFormat(date, pattern, { zone: timeZone }).toJSDate();
131
+ if (dateObject instanceof Date && !isNaN(dateObject.getTime())) {
132
+ console.log(dateObject);
133
+ return dateObject;
134
+ }
135
+ else {
136
+ return luxon_1.DateTime.fromFormat(date, 'yyyy-MM-dd', { zone: timeZone }).toJSDate();
137
+ }
131
138
  }
132
139
  exports.parseDate = parseDate;
133
140
  function getDateFormatterPattern(datePattern, periodicity) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Node.js client for Bkper REST API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",