@leancodepl/api-date-dayjs 7.2.1 → 7.2.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/index.cjs.js +16 -32
- package/index.esm.js +4 -4
- package/package.json +4 -4
- package/src/lib/date/fromApiDate.d.ts +1 -1
- package/src/lib/date/toApiDate.d.ts +1 -1
- package/src/lib/dateTimeOffset/fromApiDateTimeOffset.d.ts +1 -1
- package/src/lib/dateTimeOffset/toApiDateTimeOffset.d.ts +1 -1
- package/src/lib/time/fromApiTime.d.ts +1 -1
- package/src/lib/time/toApiTime.d.ts +1 -1
- package/src/lib/timeSpan/fromApiTimeSpan.d.ts +1 -1
- package/src/lib/timeSpan/toApiTimeSpan.d.ts +1 -1
- package/src/lib/utils/dropLocalOffset.d.ts +1 -1
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
|
|
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
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
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
|
-
|
|
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
|
|
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
|
|
35
|
+
return dayjs__default["default"](date);
|
|
52
36
|
}
|
|
53
37
|
|
|
54
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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 =
|
|
71
|
+
const dayjsDuration = dayjs__default["default"].duration(parsedDuration.values);
|
|
88
72
|
if (isNegative) {
|
|
89
|
-
return
|
|
73
|
+
return dayjs__default["default"].duration(-dayjsDuration.asMilliseconds());
|
|
90
74
|
}
|
|
91
75
|
return dayjsDuration;
|
|
92
76
|
}
|
|
93
77
|
|
|
94
|
-
|
|
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 =
|
|
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
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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
|
|
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.2.
|
|
3
|
+
"version": "7.2.3",
|
|
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.2.
|
|
10
|
-
"@leancodepl/api-date-utils": "7.2.
|
|
11
|
-
"dayjs": ">=1.
|
|
9
|
+
"@leancodepl/api-date": "7.2.3",
|
|
10
|
+
"@leancodepl/api-date-utils": "7.2.3",
|
|
11
|
+
"dayjs": ">=1.9.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"timezone-mock": "1.3.6"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApiTimeSpan } from "@leancodepl/api-date";
|
|
2
|
-
import
|
|
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
|
|
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
|
*/
|