@pigknowsdev/date-helpers 2.0.0 → 2.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 +3 -3
- package/src/dateHelpers.ts +1 -15
- package/src/types.ts +50 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pigknowsdev/date-helpers",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"author": "PigKnows Dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "ISC",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"build": "rm -rf dist && tsc"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"luxon": "^
|
|
27
|
+
"luxon": "^3.4.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.11.6",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@babel/preset-typescript": "^7.10.4",
|
|
33
33
|
"@tsconfig/node12": "^1.0.7",
|
|
34
34
|
"@tsconfig/recommended": "^1.0.1",
|
|
35
|
-
"@types/luxon": "^
|
|
35
|
+
"@types/luxon": "^3.4.2",
|
|
36
36
|
"typescript": "^4.0.3"
|
|
37
37
|
},
|
|
38
38
|
"optionalDependencies": {
|
package/src/dateHelpers.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DateTime, DateObjectUnits } from 'luxon';
|
|
2
|
+
import type { FormatNames, ReportFormats } from './types'
|
|
2
3
|
|
|
3
4
|
const currentYear = new Date().getFullYear();
|
|
4
5
|
const NEWSHAM_DAY_ZERO = '1985-06-05';
|
|
@@ -22,21 +23,6 @@ function padNum(input: number | string, places = 2) {
|
|
|
22
23
|
return temp;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
export type FormatNames = 'AMERICAN' | 'american' | 'American'
|
|
26
|
-
| 'EUROPEAN' | 'european' | 'European'
|
|
27
|
-
| 'ISO' | 'iso' | 'Iso'
|
|
28
|
-
| 'JULIAN' | 'Julian' | 'julian'
|
|
29
|
-
| 'NEWSHAM' | 'Newsham' | 'newsham'
|
|
30
|
-
| 'REGULAR' | 'Regular' | 'regular'
|
|
31
|
-
| 'THOUSAND' | 'Thousand' | 'thousand';
|
|
32
|
-
|
|
33
|
-
export type ReportFormats = '%b%d' | '%b%d%y' |
|
|
34
|
-
'%b%d%Y' | '%d%b' | '%d%b%y' | '%d%b%Y' | '%d-%m-%y' |
|
|
35
|
-
'%d/%m/%y' | '%d/%m/%Y' | '%m/%d' | '%m/%d/%y' | '%m/%d/%Y' |
|
|
36
|
-
'%d-%m-%Y' | '%m-%d' | '%m-%d-%y' | '%m-%d-%Y' | '%j' |
|
|
37
|
-
'%J' | '%N' | '%n' | '%t' | '%T' | '%y-%m-%d' | '%Y-%m-%d' |
|
|
38
|
-
'%y/%m/%d' | '%Y/%m/%d';
|
|
39
|
-
|
|
40
26
|
// dateFormatsMap requires Regular-like input
|
|
41
27
|
// convert to regular first using helper function below
|
|
42
28
|
const dateFormatsMap = {
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type FormatNames =
|
|
2
|
+
| "AMERICAN"
|
|
3
|
+
| "american"
|
|
4
|
+
| "American"
|
|
5
|
+
| "EUROPEAN"
|
|
6
|
+
| "european"
|
|
7
|
+
| "European"
|
|
8
|
+
| "ISO"
|
|
9
|
+
| "iso"
|
|
10
|
+
| "Iso"
|
|
11
|
+
| "JULIAN"
|
|
12
|
+
| "Julian"
|
|
13
|
+
| "julian"
|
|
14
|
+
| "NEWSHAM"
|
|
15
|
+
| "Newsham"
|
|
16
|
+
| "newsham"
|
|
17
|
+
| "REGULAR"
|
|
18
|
+
| "Regular"
|
|
19
|
+
| "regular"
|
|
20
|
+
| "THOUSAND"
|
|
21
|
+
| "Thousand"
|
|
22
|
+
| "thousand";
|
|
23
|
+
|
|
24
|
+
export type ReportFormats =
|
|
25
|
+
| "%b%d"
|
|
26
|
+
| "%b%d%y"
|
|
27
|
+
| "%b%d%Y"
|
|
28
|
+
| "%d%b"
|
|
29
|
+
| "%d%b%y"
|
|
30
|
+
| "%d%b%Y"
|
|
31
|
+
| "%d-%m-%y"
|
|
32
|
+
| "%d/%m/%y"
|
|
33
|
+
| "%d/%m/%Y"
|
|
34
|
+
| "%m/%d"
|
|
35
|
+
| "%m/%d/%y"
|
|
36
|
+
| "%m/%d/%Y"
|
|
37
|
+
| "%d-%m-%Y"
|
|
38
|
+
| "%m-%d"
|
|
39
|
+
| "%m-%d-%y"
|
|
40
|
+
| "%m-%d-%Y"
|
|
41
|
+
| "%j"
|
|
42
|
+
| "%J"
|
|
43
|
+
| "%N"
|
|
44
|
+
| "%n"
|
|
45
|
+
| "%t"
|
|
46
|
+
| "%T"
|
|
47
|
+
| "%y-%m-%d"
|
|
48
|
+
| "%Y-%m-%d"
|
|
49
|
+
| "%y/%m/%d"
|
|
50
|
+
| "%Y/%m/%d";
|