@leancodepl/api-date-dayjs 7.1.7 → 7.2.2

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/index.cjs.js CHANGED
@@ -9,35 +9,19 @@ var utc = require('dayjs/plugin/utc');
9
9
  var apiDateUtils = require('@leancodepl/api-date-utils');
10
10
  var duration = require('dayjs/plugin/duration');
11
11
 
12
- function _interopNamespace(e) {
13
- if (e && e.__esModule) return e;
14
- var n = Object.create(null);
15
- if (e) {
16
- Object.keys(e).forEach(function (k) {
17
- if (k !== 'default') {
18
- var d = Object.getOwnPropertyDescriptor(e, k);
19
- Object.defineProperty(n, k, d.get ? d : {
20
- enumerable: true,
21
- get: function () { return e[k]; }
22
- });
23
- }
24
- });
25
- }
26
- n["default"] = e;
27
- return Object.freeze(n);
28
- }
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
29
13
 
30
- var dayjs__namespace = /*#__PURE__*/_interopNamespace(dayjs);
31
- var customParseFormat__namespace = /*#__PURE__*/_interopNamespace(customParseFormat);
32
- var utc__namespace = /*#__PURE__*/_interopNamespace(utc);
33
- var duration__namespace = /*#__PURE__*/_interopNamespace(duration);
14
+ var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
15
+ var customParseFormat__default = /*#__PURE__*/_interopDefaultLegacy(customParseFormat);
16
+ var utc__default = /*#__PURE__*/_interopDefaultLegacy(utc);
17
+ var duration__default = /*#__PURE__*/_interopDefaultLegacy(duration);
34
18
 
35
- dayjs__namespace.extend(customParseFormat__namespace);
19
+ dayjs__default["default"].extend(customParseFormat__default["default"]);
36
20
  function fromApiTime(time) {
37
21
  if (!time) {
38
22
  return undefined;
39
23
  }
40
- return dayjs__namespace(time, "HH:mm:ss.SSS");
24
+ return dayjs__default["default"](time, "HH:mm:ss.SSS");
41
25
  }
42
26
 
43
27
  function toApiTime(time) {
@@ -48,10 +32,10 @@ function toApiTime(time) {
48
32
  }
49
33
 
50
34
  function fromApiDate(date) {
51
- return dayjs__namespace(date);
35
+ return dayjs__default["default"](date);
52
36
  }
53
37
 
54
- dayjs__namespace.extend(utc__namespace);
38
+ dayjs__default["default"].extend(utc__default["default"]);
55
39
  /**
56
40
  * This function keeps local time (excluding timezone/offset) but sets its offset to UTC
57
41
  */ function dropLocalOffset(time) {
@@ -62,12 +46,12 @@ function toApiDate(date) {
62
46
  return dropLocalOffset(date).startOf("day").format("YYYY-MM-DD");
63
47
  }
64
48
 
65
- dayjs__namespace.extend(customParseFormat__namespace);
49
+ dayjs__default["default"].extend(customParseFormat__default["default"]);
66
50
  function fromApiDateTimeOffset(datetime) {
67
51
  if (!datetime) {
68
52
  return undefined;
69
53
  }
70
- return dayjs__namespace(datetime, "YYYY-MM-DDTHH:mm:ss.SSSZ");
54
+ return dayjs__default["default"](datetime, "YYYY-MM-DDTHH:mm:ss.SSSZ");
71
55
  }
72
56
 
73
57
  function toApiDateTimeOffset(time) {
@@ -77,27 +61,27 @@ function toApiDateTimeOffset(time) {
77
61
  return time.format("YYYY-MM-DDTHH:mm:ss.SSSZ");
78
62
  }
79
63
 
80
- dayjs__namespace.extend(duration__namespace);
64
+ dayjs__default["default"].extend(duration__default["default"]);
81
65
  function fromApiTimeSpan(timeSpan) {
82
66
  if (!timeSpan) {
83
67
  return undefined;
84
68
  }
85
69
  const parsedDuration = apiDateUtils.parseApiTimeSpan(timeSpan);
86
70
  const isNegative = parsedDuration.sign === "-";
87
- const dayjsDuration = dayjs__namespace.duration(parsedDuration.values);
71
+ const dayjsDuration = dayjs__default["default"].duration(parsedDuration.values);
88
72
  if (isNegative) {
89
- return dayjs__namespace.duration(-dayjsDuration.asMilliseconds());
73
+ return dayjs__default["default"].duration(-dayjsDuration.asMilliseconds());
90
74
  }
91
75
  return dayjsDuration;
92
76
  }
93
77
 
94
- dayjs__namespace.extend(duration__namespace);
78
+ dayjs__default["default"].extend(duration__default["default"]);
95
79
  function toApiTimeSpan(duration) {
96
80
  if (!duration) {
97
81
  return undefined;
98
82
  }
99
83
  const isNegative = duration.asMilliseconds() < 0;
100
- const absDuration = dayjs__namespace.duration(Math.abs(duration.asMilliseconds()));
84
+ const absDuration = dayjs__default["default"].duration(Math.abs(duration.asMilliseconds()));
101
85
  const days = Math.floor(absDuration.asDays());
102
86
  let stringTimeSpan = "";
103
87
  if (isNegative) {
package/index.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export * from '@leancodepl/api-date';
2
- import * as dayjs from 'dayjs';
3
- import * as customParseFormat from 'dayjs/plugin/customParseFormat';
4
- import * as utc from 'dayjs/plugin/utc';
2
+ import dayjs from 'dayjs';
3
+ import customParseFormat from 'dayjs/plugin/customParseFormat';
4
+ import utc from 'dayjs/plugin/utc';
5
5
  import { parseApiTimeSpan } from '@leancodepl/api-date-utils';
6
- import * as duration from 'dayjs/plugin/duration';
6
+ import duration from 'dayjs/plugin/duration';
7
7
 
8
8
  dayjs.extend(customParseFormat);
9
9
  function fromApiTime(time) {
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@leancodepl/api-date-dayjs",
3
- "version": "7.1.7",
3
+ "version": "7.2.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "commonjs",
6
6
  "main": "./index.cjs.js",
7
7
  "module": "./index.esm.js",
8
8
  "dependencies": {
9
- "@leancodepl/api-date": "7.1.7",
10
- "@leancodepl/api-date-utils": "7.1.7",
11
- "dayjs": ">=1.0.0"
9
+ "@leancodepl/api-date": "7.2.2",
10
+ "@leancodepl/api-date-utils": "7.2.2",
11
+ "dayjs": ">=1.9.0"
12
12
  },
13
13
  "devDependencies": {
14
14
  "timezone-mock": "1.3.6"
@@ -1,3 +1,3 @@
1
1
  import type { ApiDateOnly } from "@leancodepl/api-date";
2
- import * as dayjs from "dayjs";
2
+ import dayjs from "dayjs";
3
3
  export declare function fromApiDate(date: ApiDateOnly): dayjs.Dayjs;
@@ -1,3 +1,3 @@
1
1
  import type { ApiDateOnly } from "@leancodepl/api-date";
2
- import * as dayjs from "dayjs";
2
+ import dayjs from "dayjs";
3
3
  export declare function toApiDate(date: dayjs.Dayjs): ApiDateOnly;
@@ -1,5 +1,5 @@
1
1
  import type { ApiDateTimeOffset } from "@leancodepl/api-date";
2
- import * as dayjs from "dayjs";
2
+ import dayjs from "dayjs";
3
3
  /**
4
4
  *This function handles at most milliseconds precision, smaller units are lost in conversion process
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import type { ApiDateTimeOffset } from "@leancodepl/api-date";
2
- import * as dayjs from "dayjs";
2
+ import dayjs from "dayjs";
3
3
  /**
4
4
  *This function handles at most milliseconds precision, smaller units are lost in conversion process
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import type { ApiTimeOnly } from "@leancodepl/api-date";
2
- import * as dayjs from "dayjs";
2
+ import dayjs from "dayjs";
3
3
  /**
4
4
  *This function handles at most milliseconds precision, smaller units are lost in conversion process
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import type { ApiTimeOnly } from "@leancodepl/api-date";
2
- import * as dayjs from "dayjs";
2
+ import dayjs from "dayjs";
3
3
  /**
4
4
  *This function handles at most milliseconds precision, smaller units are lost in conversion process
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import type { ApiTimeSpan } from "@leancodepl/api-date";
2
- import * as duration from "dayjs/plugin/duration";
2
+ import duration from "dayjs/plugin/duration";
3
3
  /**
4
4
  *This function handles at most milliseconds precision, smaller units are lost in conversion process
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import type { ApiTimeSpan } from "@leancodepl/api-date";
2
- import * as duration from "dayjs/plugin/duration";
2
+ import duration from "dayjs/plugin/duration";
3
3
  /**
4
4
  *This function handles at most milliseconds precision, smaller units are lost in conversion process
5
5
  */
@@ -1,4 +1,4 @@
1
- import * as dayjs from "dayjs";
1
+ import dayjs from "dayjs";
2
2
  /**
3
3
  * This function keeps local time (excluding timezone/offset) but sets its offset to UTC
4
4
  */