@pigknowsdev/date-helpers 2.0.0 → 2.0.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/README.md +24 -6
- package/dist/cjs/dateHelpers.d.ts +10 -0
- package/dist/cjs/dateHelpers.js +670 -0
- package/dist/cjs/dateHelpers.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.d.ts +2 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/dateHelpers.d.ts +5 -5
- package/dist/dateHelpers.js +73 -46
- package/dist/dateHelpers.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +13 -7
- package/src/dateHelpers.ts +125 -61
- package/src/index.ts +3 -1
- package/src/types.ts +50 -0
package/README.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Supports conversions from all of PigKnows date formats from any format into any other format.
|
|
4
4
|
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
yarn add @pigknowsdev/date-helpers
|
|
8
|
+
|
|
9
|
+
The package ships a CommonJS build for Node (`require`) and an ES module build for bundlers.
|
|
10
|
+
|
|
11
|
+
The source lives at https://github.com/pigknows/pk-date-helpers. The package on npm is `@pigknowsdev/date-helpers`; the older unscoped `pk-date-helpers` package is no longer updated.
|
|
12
|
+
|
|
13
|
+
## Releasing
|
|
14
|
+
|
|
15
|
+
GitHub Actions publishes to npm when a version tag is pushed (`.github/workflows/publish.yml`). It builds `dist/` from `src/`; `dist/` is not committed.
|
|
16
|
+
|
|
17
|
+
1. Merge the change into `main`.
|
|
18
|
+
2. On an up-to-date `main`, run `npm version <new version>`, for example `npm version 2.2.0`. This updates `package.json`, commits, and creates the tag `v2.2.0`.
|
|
19
|
+
3. Push the commit and the tag: `git push origin main --follow-tags`.
|
|
20
|
+
|
|
21
|
+
The workflow fails if the tag does not match the version in `package.json`. After it finishes, bump `@pigknowsdev/date-helpers` in each app that should get the change.
|
|
22
|
+
|
|
5
23
|
## Supported Standard Formats:
|
|
6
24
|
1. American (MM-dd-yyyy)
|
|
7
25
|
2. European (dd-MM-yyyy)
|
|
@@ -44,7 +62,7 @@ Supports conversions from all of PigKnows date formats from any format into any
|
|
|
44
62
|
#### convertDateToFormatType
|
|
45
63
|
Usage:
|
|
46
64
|
|
|
47
|
-
import { convertDateToFormatType } from '
|
|
65
|
+
import { convertDateToFormatType } from '@pigknowsdev/date-helpers';
|
|
48
66
|
|
|
49
67
|
...
|
|
50
68
|
|
|
@@ -53,7 +71,7 @@ Supports conversions from all of PigKnows date formats from any format into any
|
|
|
53
71
|
#### convertDateToRegularString
|
|
54
72
|
Usage:
|
|
55
73
|
|
|
56
|
-
import { convertDateToRegularString } from '
|
|
74
|
+
import { convertDateToRegularString } from '@pigknowsdev/date-helpers';
|
|
57
75
|
|
|
58
76
|
...
|
|
59
77
|
|
|
@@ -66,7 +84,7 @@ Used for % style date formats instead of the string formats ("European", "THOUSA
|
|
|
66
84
|
|
|
67
85
|
Usage:
|
|
68
86
|
|
|
69
|
-
import { convertPercentDateFormat } from '
|
|
87
|
+
import { convertPercentDateFormat } from '@pigknowsdev/date-helpers';
|
|
70
88
|
|
|
71
89
|
...
|
|
72
90
|
|
|
@@ -94,7 +112,7 @@ Converts a shortcut of any format into its long form. For example, converting `0
|
|
|
94
112
|
|
|
95
113
|
Usage:
|
|
96
114
|
|
|
97
|
-
import { convertShortcutDate } from '
|
|
115
|
+
import { convertShortcutDate } from '@pigknowsdev/date-helpers';
|
|
98
116
|
|
|
99
117
|
...
|
|
100
118
|
|
|
@@ -107,7 +125,7 @@ Detects the format of a string, if it matches a known date format. Optional para
|
|
|
107
125
|
|
|
108
126
|
Usage:
|
|
109
127
|
|
|
110
|
-
import { detectFormatType } from '
|
|
128
|
+
import { detectFormatType } from '@pigknowsdev/date-helpers';
|
|
111
129
|
|
|
112
130
|
...
|
|
113
131
|
|
|
@@ -130,7 +148,7 @@ Returns an array of formats that may appear the same from a regex / structure pe
|
|
|
130
148
|
|
|
131
149
|
Usage:
|
|
132
150
|
|
|
133
|
-
import { getConflictingFormatsForType } from '
|
|
151
|
+
import { getConflictingFormatsForType } from '@pigknowsdev/date-helpers';
|
|
134
152
|
|
|
135
153
|
...
|
|
136
154
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FormatNames, ReportFormats } from './types.js';
|
|
2
|
+
export type { FormatNames, ReportFormats } from './types.js';
|
|
3
|
+
export declare function detectFormatType(date: string, preferStandard?: boolean, ignoreFormats?: string[]): string;
|
|
4
|
+
export declare function getConflictingFormatsForType(formatType: FormatNames | ReportFormats): any;
|
|
5
|
+
export declare function convertDateToRegularString(inputFormat: FormatNames | ReportFormats, date: string, daysAheadAllowed?: number): string;
|
|
6
|
+
export declare function convertDateToFormatType(inputFormatType: FormatNames | ReportFormats, destinationFormatType: FormatNames, date: string, daysAheadAllowed?: number): string;
|
|
7
|
+
export declare function detectIfFutureDate(regularDate: any): boolean;
|
|
8
|
+
export declare function detectIfValidPKDate(regularDate: any): boolean;
|
|
9
|
+
export declare function convertShortcutDate(formatType: FormatNames, date: string, daysAheadAllowed?: number): string;
|
|
10
|
+
export declare function convertPercentDateFormat(destinationFormat: ReportFormats | 'default', date: string): string;
|