wsp-ms-core 1.1.13 → 1.1.15

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/dist/index.cjs CHANGED
@@ -103,9 +103,13 @@ var ValueObject = class {
103
103
 
104
104
  // src/domain/value-objects/DateTime.ts
105
105
  var _DateTime = class _DateTime extends ValueObject {
106
- constructor(value) {
106
+ constructor(value, strictUTC = true) {
107
107
  super(value);
108
- this._dt = import_luxon.DateTime.fromFormat(value, _DateTime.DEFAULT_FORMAT, { zone: "utc" });
108
+ if (strictUTC) {
109
+ this._dt = import_luxon.DateTime.fromFormat(value, _DateTime.DEFAULT_FORMAT, { zone: "utc" });
110
+ } else {
111
+ this._dt = import_luxon.DateTime.fromFormat(value, _DateTime.DEFAULT_FORMAT);
112
+ }
109
113
  }
110
114
  static fromLuxon(dt) {
111
115
  return new _DateTime(_DateTime.toUtcFormat(dt));
@@ -242,6 +246,25 @@ var _DateTime = class _DateTime extends ValueObject {
242
246
  value: this.value
243
247
  };
244
248
  }
249
+ setTimeZone(timeZone, options) {
250
+ let dt;
251
+ if (options) {
252
+ dt = this._dt.setZone(timeZone, options);
253
+ } else {
254
+ dt = this._dt.setZone(timeZone);
255
+ }
256
+ if (!dt.isValid) {
257
+ throw new Error("Invalid date");
258
+ }
259
+ return new _DateTime(dt.toFormat(_DateTime.DEFAULT_FORMAT), false);
260
+ }
261
+ formatInTimezone(timezone) {
262
+ const zoned = this._dt.setZone(timezone);
263
+ if (!zoned.isValid) {
264
+ throw new Error(`Invalid timezone: ${timezone}`);
265
+ }
266
+ return zoned.toFormat(_DateTime.DEFAULT_FORMAT);
267
+ }
245
268
  static create(input) {
246
269
  if (input === void 0) {
247
270
  return new _DateTime(_DateTime.toUtcFormat(import_luxon.DateTime.now()));
@@ -269,6 +292,8 @@ _DateTime.FORMAT_Y_M_D_H_m_s = "Y-M-D H:M:S";
269
292
  _DateTime.FORMAT_D_M_Y = "D-M-Y";
270
293
  _DateTime.COMPARE_UNIT_MILLIS = "millis";
271
294
  _DateTime.COMPARE_UNIT_DAY = "day";
295
+ _DateTime.TIMEZONE_UTC = "utc";
296
+ _DateTime.TIMEZONE_URUGUAY = "America/Montevideo";
272
297
  _DateTime.FORMATS = {
273
298
  "Y-M": "yyyy-MM",
274
299
  "Y-M-D": "yyyy-MM-dd",