@autometa/datetime 0.1.16 → 1.0.0-rc.0
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 +47 -2
- package/dist/dates/clock.d.ts +5 -0
- package/dist/dates/date-factory.d.ts +20 -0
- package/dist/dates/formatted-date-factory.d.ts +23 -0
- package/dist/dates/iso-date-factory.d.ts +23 -0
- package/dist/dates/object.d.ts +28 -0
- package/dist/dates/time-units.d.ts +6 -0
- package/dist/index.cjs +482 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -219
- package/dist/index.js +349 -481
- package/dist/index.js.map +1 -1
- package/dist/shared/phrases.d.ts +2 -0
- package/dist/time/time-diff.d.ts +12 -0
- package/dist/time/time.d.ts +7 -0
- package/package.json +29 -24
- package/.eslintignore +0 -3
- package/.eslintrc.cjs +0 -4
- package/CHANGELOG.md +0 -141
- package/dist/esm/index.js +0 -573
- package/dist/esm/index.js.map +0 -1
- package/dist/index.d.cts +0 -219
- package/tsup.config.ts +0 -14
package/dist/index.d.cts
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { TimeUnit } from '@autometa/phrases';
|
|
2
|
-
|
|
3
|
-
type TimeShortcut = "now" | "beforeYesterday" | "yesterday" | "today" | "tomorrow" | "afterTomorrow" | "midnight" | "lastWeek" | "nextWeek" | "lastFortnight" | "nextFortnight";
|
|
4
|
-
declare class DateFactory {
|
|
5
|
-
#private;
|
|
6
|
-
phraseMap: Map<TimeShortcut, () => Date>;
|
|
7
|
-
find(name: TimeShortcut): Date;
|
|
8
|
-
fromPhraseSafe(phrase: string): Date | undefined;
|
|
9
|
-
fromPhrase(phrase: string): Date;
|
|
10
|
-
make(timeOffset: number, timeunit: TimeUnit): Date;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare class IsoDateFactory {
|
|
14
|
-
readonly dateFactory: DateFactory;
|
|
15
|
-
constructor(dateFactory: DateFactory);
|
|
16
|
-
phraseMap: Map<string, string>;
|
|
17
|
-
make(daysOffset: number, timeunit: TimeUnit): string;
|
|
18
|
-
/**
|
|
19
|
-
* Attempts to parse a phrase into a date.
|
|
20
|
-
* @param phrase
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
fromPhrase(phrase: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Returns the date and time of the day before yesterday
|
|
26
|
-
*/
|
|
27
|
-
get beforeYesterday(): string | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Returns the date and time of yesterday
|
|
30
|
-
*/
|
|
31
|
-
get yesterday(): string | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Returns the date and time of today
|
|
34
|
-
*/
|
|
35
|
-
get today(): string | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Returns the date and time of tomorrow
|
|
38
|
-
*/
|
|
39
|
-
get tomorrow(): string | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Returns the date and time of the day after tomorrow
|
|
42
|
-
*/
|
|
43
|
-
get afterTomorrow(): string | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* Returns the date and time of midnight today
|
|
46
|
-
*/
|
|
47
|
-
get midnight(): string | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Returns the date and time of today 1 week ago
|
|
50
|
-
*/
|
|
51
|
-
get lastWeek(): string | undefined;
|
|
52
|
-
/**
|
|
53
|
-
* Returns the date and time of today 1 week from now
|
|
54
|
-
*/
|
|
55
|
-
get nextWeek(): string | undefined;
|
|
56
|
-
get lastFortnight(): string | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* Returns the date and time of today 1 fortnight from now
|
|
59
|
-
*/
|
|
60
|
-
get nextFortnight(): string | undefined;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
declare class FmtDateFactory {
|
|
64
|
-
readonly dateFactory: DateFactory;
|
|
65
|
-
constructor(dateFactory: DateFactory);
|
|
66
|
-
phraseMap: Map<string, string>;
|
|
67
|
-
make(daysOffset: number, timeunit: TimeUnit): string;
|
|
68
|
-
/**
|
|
69
|
-
* Attempts to parse a phrase into a date.
|
|
70
|
-
* @param phrase
|
|
71
|
-
* @returns
|
|
72
|
-
*/
|
|
73
|
-
fromPhrase(phrase: string): string;
|
|
74
|
-
/**
|
|
75
|
-
* Returns the date and time of the day before yesterday
|
|
76
|
-
*/
|
|
77
|
-
get beforeYesterday(): string | undefined;
|
|
78
|
-
/**
|
|
79
|
-
* Returns the date and time of yesterday
|
|
80
|
-
*/
|
|
81
|
-
get yesterday(): string | undefined;
|
|
82
|
-
/**
|
|
83
|
-
* Returns the date and time of today
|
|
84
|
-
*/
|
|
85
|
-
get today(): string | undefined;
|
|
86
|
-
/**
|
|
87
|
-
* Returns the date and time of tomorrow
|
|
88
|
-
*/
|
|
89
|
-
get tomorrow(): string | undefined;
|
|
90
|
-
/**
|
|
91
|
-
* Returns the date and time of the day after tomorrow
|
|
92
|
-
*/
|
|
93
|
-
get afterTomorrow(): string | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* Returns the date and time of midnight today
|
|
96
|
-
*/
|
|
97
|
-
get midnight(): string | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* Returns the date and time of today 1 week ago
|
|
100
|
-
*/
|
|
101
|
-
get lastWeek(): string | undefined;
|
|
102
|
-
/**
|
|
103
|
-
* Returns the date and time of today 1 week from now
|
|
104
|
-
*/
|
|
105
|
-
get nextWeek(): string | undefined;
|
|
106
|
-
/**
|
|
107
|
-
* Returns the date and time of today 1 fortnight ago
|
|
108
|
-
*/
|
|
109
|
-
get lastFortnight(): string | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* Returns the date and time of today 1 fortnight from now
|
|
112
|
-
*/
|
|
113
|
-
get nextFortnight(): string | undefined;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
declare class DatesObject {
|
|
117
|
-
#private;
|
|
118
|
-
/**
|
|
119
|
-
* Switches to the ISO factory, which offers an identical interface
|
|
120
|
-
* but returns ISO strings instead of Date objects.
|
|
121
|
-
*
|
|
122
|
-
* Example: `2020-01-01T00:00:00.000Z`
|
|
123
|
-
*/
|
|
124
|
-
get iso(): IsoDateFactory;
|
|
125
|
-
/**
|
|
126
|
-
* Switches to the formatted factory, which offers an identical interface
|
|
127
|
-
* but returns formatted strings instead of Date objects.
|
|
128
|
-
*
|
|
129
|
-
* Example: `2020-01-01`
|
|
130
|
-
*/
|
|
131
|
-
get fmt(): FmtDateFactory;
|
|
132
|
-
/**
|
|
133
|
-
* Returns the current date and time.
|
|
134
|
-
*/
|
|
135
|
-
get now(): Date;
|
|
136
|
-
/**
|
|
137
|
-
* Returns the date and time of the day before yesterday
|
|
138
|
-
*/
|
|
139
|
-
get beforeYesterday(): Date;
|
|
140
|
-
/**
|
|
141
|
-
* Returns the date and time of yesterday
|
|
142
|
-
*/
|
|
143
|
-
get yesterday(): Date;
|
|
144
|
-
/**
|
|
145
|
-
* Returns the date and time of today
|
|
146
|
-
*/
|
|
147
|
-
get today(): Date;
|
|
148
|
-
/**
|
|
149
|
-
* Returns the date and time of tomorrow
|
|
150
|
-
*/
|
|
151
|
-
get tomorrow(): Date;
|
|
152
|
-
/**
|
|
153
|
-
* Returns the date and time of the day after tomorrow
|
|
154
|
-
*/
|
|
155
|
-
get afterTomorrow(): Date;
|
|
156
|
-
/**
|
|
157
|
-
* Returns the date and time of midnight today
|
|
158
|
-
*/
|
|
159
|
-
get midnight(): Date;
|
|
160
|
-
/**
|
|
161
|
-
* Returns the date and time of today 1 week ago
|
|
162
|
-
*/
|
|
163
|
-
get lastWeek(): Date;
|
|
164
|
-
/**
|
|
165
|
-
* Returns the date and time of today 1 week from now
|
|
166
|
-
*/
|
|
167
|
-
get nextWeek(): Date;
|
|
168
|
-
/**
|
|
169
|
-
* Returns the date and time of today 2 weeks ago
|
|
170
|
-
*/
|
|
171
|
-
get lastFortnight(): Date;
|
|
172
|
-
/**
|
|
173
|
-
* Returns the date and time of today 2 weeks from now
|
|
174
|
-
*/
|
|
175
|
-
get nextFortnight(): Date;
|
|
176
|
-
/**
|
|
177
|
-
* Attempts to parse a phrase into a date.
|
|
178
|
-
* @param phrase
|
|
179
|
-
* @returns
|
|
180
|
-
*/
|
|
181
|
-
fromPhrase(phrase: string): Date;
|
|
182
|
-
/**
|
|
183
|
-
* Attempts to parse a phrase into a date.
|
|
184
|
-
* If the phrase is invalid, it will return an invalid date instead of throwing.
|
|
185
|
-
* @param phrase
|
|
186
|
-
* @returns
|
|
187
|
-
*/
|
|
188
|
-
fromPhraseSafe(phrase: string): Date | undefined;
|
|
189
|
-
make(timeOffset: number, timeUnit: TimeUnit): Date;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Date utility option to easily generate common
|
|
193
|
-
* dates around the current date, like 'today', 'midnight',
|
|
194
|
-
* 'tomorrow', 'nextWeek', etc.
|
|
195
|
-
*
|
|
196
|
-
* The Dates utility also supports certain language phrases
|
|
197
|
-
* that might be natural in Cucumber's gherkin syntax, like
|
|
198
|
-
* 'next week', 'last week', 'next fortnight', etc. as well
|
|
199
|
-
* as more dynamic phrases like `1 day ago`, `2 weeks from now`,
|
|
200
|
-
*/
|
|
201
|
-
declare const Dates: DatesObject;
|
|
202
|
-
|
|
203
|
-
type TimeDiffFn = (date1: Date, date2: Date) => number;
|
|
204
|
-
declare class TimeDiff {
|
|
205
|
-
minutes(date1: Date, date2: Date): number;
|
|
206
|
-
seconds(date1: Date, date2: Date): number;
|
|
207
|
-
millis(date1: Date, date2: Date): number;
|
|
208
|
-
days(date1: Date, date2: Date): number;
|
|
209
|
-
hours(date1: Date, date2: Date): number;
|
|
210
|
-
weeks(date1: Date, date2: Date): number;
|
|
211
|
-
fromPhrase(phrase: string): TimeDiffFn;
|
|
212
|
-
}
|
|
213
|
-
declare class TimeObject {
|
|
214
|
-
#private;
|
|
215
|
-
get diff(): TimeDiff;
|
|
216
|
-
}
|
|
217
|
-
declare const Time: TimeObject;
|
|
218
|
-
|
|
219
|
-
export { DateFactory, Dates, FmtDateFactory, IsoDateFactory, Time, TimeDiff, TimeObject };
|
package/tsup.config.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
clean: true, // clean up the dist folder
|
|
5
|
-
sourcemap:true, // generate sourcemaps
|
|
6
|
-
format: ["cjs", "esm"], // generate cjs and esm files
|
|
7
|
-
dts: true,
|
|
8
|
-
skipNodeModulesBundle: true,
|
|
9
|
-
entryPoints: ["src/index.ts"],
|
|
10
|
-
target: "es2020",
|
|
11
|
-
outDir: "dist",
|
|
12
|
-
legacyOutput: true,
|
|
13
|
-
external: ["dist"],
|
|
14
|
-
});
|