@sjts/lib-date 13.0.0 → 19.0.1
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sjts/lib-date",
|
|
3
3
|
"description": "The Steve James Typescript date utils package",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "19.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -12,12 +12,17 @@
|
|
|
12
12
|
"require": "./dist/index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc"
|
|
17
|
+
},
|
|
18
|
+
"prettier": "@sjts/lib-devops/prettier.json",
|
|
15
19
|
"dependencies": {
|
|
16
20
|
"lodash-es": "4.17.21",
|
|
17
21
|
"luxon": "3.1.1"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
|
-
"@sjts/lib-
|
|
24
|
+
"@sjts/lib-devops": "workspace:*",
|
|
25
|
+
"typescript": "^5.8.3"
|
|
21
26
|
},
|
|
22
27
|
"publishConfig": {
|
|
23
28
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { unitTest } from '@sjts/lib-dev';
|
|
2
|
-
import { calcDateRangeDiff } from './calcDateRangeDiff';
|
|
3
|
-
import { newDateFromISO } from './newDateFromISO';
|
|
4
|
-
const file = 'File';
|
|
5
|
-
const arg = 'Arg';
|
|
6
|
-
describe('calcDateRangeOverlap', () => {
|
|
7
|
-
unitTest('good - month', async () => {
|
|
8
|
-
const t = {
|
|
9
|
-
startDate: newDateFromISO('2000-01-01'),
|
|
10
|
-
endDate: newDateFromISO('2000-02-01'),
|
|
11
|
-
};
|
|
12
|
-
const r = calcDateRangeDiff(t);
|
|
13
|
-
expect(r).toBe(31);
|
|
14
|
-
});
|
|
15
|
-
unitTest('good - 2 days', async () => {
|
|
16
|
-
const t = {
|
|
17
|
-
startDate: newDateFromISO('2000-01-01'),
|
|
18
|
-
endDate: newDateFromISO('2000-01-03'),
|
|
19
|
-
};
|
|
20
|
-
const r = calcDateRangeDiff(t);
|
|
21
|
-
expect(r).toBe(2);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { unitTest } from '@sjts/lib-dev';
|
|
2
|
-
import { calcDateRangeOverlap } from './calcDateRangeOverlap';
|
|
3
|
-
import { newDateFromISO } from './newDateFromISO';
|
|
4
|
-
const file = 'File';
|
|
5
|
-
const arg = 'Arg';
|
|
6
|
-
describe('calcDateRangeOverlap', () => {
|
|
7
|
-
const testRange = {
|
|
8
|
-
startDate: newDateFromISO('2000-01-01'),
|
|
9
|
-
endDate: newDateFromISO('2000-02-01'),
|
|
10
|
-
};
|
|
11
|
-
unitTest('good - fully inside', async () => {
|
|
12
|
-
const t = {
|
|
13
|
-
startDate: newDateFromISO('2000-01-10'),
|
|
14
|
-
endDate: newDateFromISO('2000-01-12'),
|
|
15
|
-
};
|
|
16
|
-
const r = calcDateRangeOverlap(testRange, t);
|
|
17
|
-
expect(r?.startDate === t.startDate).toBeTruthy();
|
|
18
|
-
expect(r?.endDate === t.endDate).toBeTruthy();
|
|
19
|
-
});
|
|
20
|
-
unitTest('good - fully outside after', async () => {
|
|
21
|
-
const t = {
|
|
22
|
-
startDate: newDateFromISO('2000-03-01'),
|
|
23
|
-
endDate: newDateFromISO('2000-03-10'),
|
|
24
|
-
};
|
|
25
|
-
const r = calcDateRangeOverlap(testRange, t);
|
|
26
|
-
expect(r).toBeUndefined();
|
|
27
|
-
});
|
|
28
|
-
unitTest('good - fully outside before', async () => {
|
|
29
|
-
const t = {
|
|
30
|
-
startDate: newDateFromISO('1999-03-01'),
|
|
31
|
-
endDate: newDateFromISO('1999-03-10'),
|
|
32
|
-
};
|
|
33
|
-
const r = calcDateRangeOverlap(testRange, t);
|
|
34
|
-
expect(r).toBeUndefined();
|
|
35
|
-
});
|
|
36
|
-
unitTest('good - fully overlap', async () => {
|
|
37
|
-
const t = {
|
|
38
|
-
startDate: newDateFromISO('1999-03-01'),
|
|
39
|
-
endDate: newDateFromISO('2003-03-10'),
|
|
40
|
-
};
|
|
41
|
-
const r = calcDateRangeOverlap(testRange, t);
|
|
42
|
-
expect(r?.startDate === testRange.startDate).toBeTruthy();
|
|
43
|
-
expect(r?.endDate === testRange.endDate).toBeTruthy();
|
|
44
|
-
});
|
|
45
|
-
unitTest('good - part overlap - before', async () => {
|
|
46
|
-
const t = {
|
|
47
|
-
startDate: newDateFromISO('1999-03-01'),
|
|
48
|
-
endDate: newDateFromISO('2000-01-10'),
|
|
49
|
-
};
|
|
50
|
-
const r = calcDateRangeOverlap(testRange, t);
|
|
51
|
-
expect(r?.startDate === testRange.startDate).toBeTruthy();
|
|
52
|
-
expect(r?.endDate === t.endDate).toBeTruthy();
|
|
53
|
-
});
|
|
54
|
-
unitTest('good - part overlap - after', async () => {
|
|
55
|
-
const t = {
|
|
56
|
-
startDate: newDateFromISO('2000-01-10'),
|
|
57
|
-
endDate: newDateFromISO('2000-03-10'),
|
|
58
|
-
};
|
|
59
|
-
const r = calcDateRangeOverlap(testRange, t);
|
|
60
|
-
expect(r?.startDate === t.startDate).toBeTruthy();
|
|
61
|
-
expect(r?.endDate === testRange.endDate).toBeTruthy();
|
|
62
|
-
});
|
|
63
|
-
});
|