@dereekb/date 0.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/README.md +7 -0
- package/package.json +19 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +7 -0
- package/src/index.js.map +1 -0
- package/src/lib/date/date.calendar.d.ts +29 -0
- package/src/lib/date/date.calendar.js +54 -0
- package/src/lib/date/date.calendar.js.map +1 -0
- package/src/lib/date/date.d.ts +61 -0
- package/src/lib/date/date.duration.d.ts +9 -0
- package/src/lib/date/date.duration.js +35 -0
- package/src/lib/date/date.duration.js.map +1 -0
- package/src/lib/date/date.format.d.ts +11 -0
- package/src/lib/date/date.format.js +60 -0
- package/src/lib/date/date.format.js.map +1 -0
- package/src/lib/date/date.hashset.d.ts +4 -0
- package/src/lib/date/date.hashset.js +11 -0
- package/src/lib/date/date.hashset.js.map +1 -0
- package/src/lib/date/date.js +131 -0
- package/src/lib/date/date.js.map +1 -0
- package/src/lib/date/date.range.d.ts +107 -0
- package/src/lib/date/date.range.js +222 -0
- package/src/lib/date/date.range.js.map +1 -0
- package/src/lib/date/date.round.d.ts +14 -0
- package/src/lib/date/date.round.js +48 -0
- package/src/lib/date/date.round.js.map +1 -0
- package/src/lib/date/date.sort.d.ts +10 -0
- package/src/lib/date/date.sort.js +25 -0
- package/src/lib/date/date.sort.js.map +1 -0
- package/src/lib/date/date.time.d.ts +82 -0
- package/src/lib/date/date.time.js +208 -0
- package/src/lib/date/date.time.js.map +1 -0
- package/src/lib/date/date.time.limit.d.ts +59 -0
- package/src/lib/date/date.time.limit.js +93 -0
- package/src/lib/date/date.time.limit.js.map +1 -0
- package/src/lib/date/date.time.minute.d.ts +73 -0
- package/src/lib/date/date.time.minute.js +104 -0
- package/src/lib/date/date.time.minute.js.map +1 -0
- package/src/lib/date/date.timezone.d.ts +74 -0
- package/src/lib/date/date.timezone.js +126 -0
- package/src/lib/date/date.timezone.js.map +1 -0
- package/src/lib/date/date.unix.d.ts +6 -0
- package/src/lib/date/date.unix.js +41 -0
- package/src/lib/date/date.unix.js.map +1 -0
- package/src/lib/date/index.d.ts +13 -0
- package/src/lib/date/index.js +17 -0
- package/src/lib/date/index.js.map +1 -0
- package/src/lib/date.request.d.ts +22 -0
- package/src/lib/date.request.js +3 -0
- package/src/lib/date.request.js.map +1 -0
- package/src/lib/expires/expires.d.ts +39 -0
- package/src/lib/expires/expires.js +74 -0
- package/src/lib/expires/expires.js.map +1 -0
- package/src/lib/expires/index.d.ts +1 -0
- package/src/lib/expires/index.js +5 -0
- package/src/lib/expires/index.js.map +1 -0
- package/src/lib/rrule/date.recurrence.d.ts +60 -0
- package/src/lib/rrule/date.recurrence.js +84 -0
- package/src/lib/rrule/date.recurrence.js.map +1 -0
- package/src/lib/rrule/date.rrule.d.ts +125 -0
- package/src/lib/rrule/date.rrule.extension.d.ts +74 -0
- package/src/lib/rrule/date.rrule.extension.js +147 -0
- package/src/lib/rrule/date.rrule.extension.js.map +1 -0
- package/src/lib/rrule/date.rrule.js +180 -0
- package/src/lib/rrule/date.rrule.js.map +1 -0
- package/src/lib/rrule/date.rrule.parse.d.ts +114 -0
- package/src/lib/rrule/date.rrule.parse.js +131 -0
- package/src/lib/rrule/date.rrule.parse.js.map +1 -0
- package/src/lib/rrule/index.d.ts +4 -0
- package/src/lib/rrule/index.js +8 -0
- package/src/lib/rrule/index.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dereekb/date",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"date-fns": "2.28.0",
|
|
7
|
+
"date-fns-tz": "1.2.2",
|
|
8
|
+
"class-transformer": "0.5.1",
|
|
9
|
+
"class-validator": "0.13.2",
|
|
10
|
+
"reflect-metadata": "0.1.13",
|
|
11
|
+
"rrule": "2.6.8"
|
|
12
|
+
},
|
|
13
|
+
"main": "./src/index.js",
|
|
14
|
+
"typings": "./src/index.d.ts",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@dereekb/util": "0.0.1",
|
|
17
|
+
"extra-set": "^2.2.11"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./lib/date"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./lib/expires"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./lib/rrule"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/date/src/index.ts"],"names":[],"mappings":";;;AAAA,0DAA2B;AAC3B,6DAA8B;AAC9B,2DAA4B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ISO8601DayString } from '@dereekb/util';
|
|
2
|
+
import { DateDurationSpan } from './date.duration';
|
|
3
|
+
/**
|
|
4
|
+
* CalendarDateType
|
|
5
|
+
*/
|
|
6
|
+
export declare enum CalendarDateType {
|
|
7
|
+
/**
|
|
8
|
+
* Event starts at a specific time and lasts for a certain duration.
|
|
9
|
+
*/
|
|
10
|
+
TIME = "time",
|
|
11
|
+
/**
|
|
12
|
+
* Event is specifically for a number of days. Duration is still tracked in minutes.
|
|
13
|
+
*/
|
|
14
|
+
DAYS = "days"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Represents a date on a calendar.
|
|
18
|
+
*/
|
|
19
|
+
export declare class CalendarDate extends DateDurationSpan {
|
|
20
|
+
/**
|
|
21
|
+
* The type of event date.
|
|
22
|
+
*/
|
|
23
|
+
type: CalendarDateType;
|
|
24
|
+
constructor(template: CalendarDate);
|
|
25
|
+
}
|
|
26
|
+
export declare class CalendarDateUtility {
|
|
27
|
+
static calendarDateForDay(day: ISO8601DayString, days?: number): CalendarDate;
|
|
28
|
+
static calendarDateForDateDurationSpan(dateDurationSpan: DateDurationSpan): CalendarDate;
|
|
29
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CalendarDateUtility = exports.CalendarDate = exports.CalendarDateType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const class_transformer_1 = require("class-transformer");
|
|
6
|
+
const date_1 = require("./date");
|
|
7
|
+
const date_duration_1 = require("./date.duration");
|
|
8
|
+
const date_format_1 = require("./date.format");
|
|
9
|
+
/**
|
|
10
|
+
* CalendarDateType
|
|
11
|
+
*/
|
|
12
|
+
var CalendarDateType;
|
|
13
|
+
(function (CalendarDateType) {
|
|
14
|
+
/**
|
|
15
|
+
* Event starts at a specific time and lasts for a certain duration.
|
|
16
|
+
*/
|
|
17
|
+
CalendarDateType["TIME"] = "time";
|
|
18
|
+
/**
|
|
19
|
+
* Event is specifically for a number of days. Duration is still tracked in minutes.
|
|
20
|
+
*/
|
|
21
|
+
CalendarDateType["DAYS"] = "days";
|
|
22
|
+
})(CalendarDateType = exports.CalendarDateType || (exports.CalendarDateType = {}));
|
|
23
|
+
/**
|
|
24
|
+
* Represents a date on a calendar.
|
|
25
|
+
*/
|
|
26
|
+
class CalendarDate extends date_duration_1.DateDurationSpan {
|
|
27
|
+
constructor(template) {
|
|
28
|
+
super(template);
|
|
29
|
+
/**
|
|
30
|
+
* The type of event date.
|
|
31
|
+
*/
|
|
32
|
+
this.type = CalendarDateType.TIME;
|
|
33
|
+
this.type = template.type;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
(0, tslib_1.__decorate)([
|
|
37
|
+
(0, class_transformer_1.Expose)(),
|
|
38
|
+
(0, tslib_1.__metadata)("design:type", String)
|
|
39
|
+
], CalendarDate.prototype, "type", void 0);
|
|
40
|
+
exports.CalendarDate = CalendarDate;
|
|
41
|
+
class CalendarDateUtility {
|
|
42
|
+
static calendarDateForDay(day, days) {
|
|
43
|
+
return {
|
|
44
|
+
type: CalendarDateType.DAYS,
|
|
45
|
+
startsAt: (0, date_format_1.dateStringToDate)(day),
|
|
46
|
+
duration: (0, date_1.daysToMinutes)(days)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
static calendarDateForDateDurationSpan(dateDurationSpan) {
|
|
50
|
+
return Object.assign({ type: CalendarDateType.TIME }, dateDurationSpan);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.CalendarDateUtility = CalendarDateUtility;
|
|
54
|
+
//# sourceMappingURL=date.calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.calendar.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/date/date.calendar.ts"],"names":[],"mappings":";;;;AACA,yDAA2C;AAC3C,iCAAuC;AACvC,mDAAmD;AACnD,+CAAiD;AAEjD;;GAEG;AACH,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B;;OAEG;IACH,iCAAa,CAAA;IACb;;OAEG;IACH,iCAAa,CAAA;AACf,CAAC,EATW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAS3B;AAED;;GAEG;AACH,MAAa,YAAa,SAAQ,gCAAgB;IAQhD,YAAY,QAAsB;QAChC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAPlB;;WAEG;QAEH,SAAI,GAAqB,gBAAgB,CAAC,IAAI,CAAC;QAI7C,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;CAEF;AAPC;IADC,IAAA,0BAAM,GAAE;;0CACsC;AANjD,oCAaC;AAED,MAAa,mBAAmB;IAE9B,MAAM,CAAC,kBAAkB,CAAC,GAAqB,EAAE,IAAa;QAC5D,OAAO;YACL,IAAI,EAAE,gBAAgB,CAAC,IAAI;YAC3B,QAAQ,EAAE,IAAA,8BAAgB,EAAC,GAAG,CAAC;YAC/B,QAAQ,EAAE,IAAA,oBAAa,EAAC,IAAI,CAAC;SAC9B,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,+BAA+B,CAAC,gBAAkC;QACvE,uBACE,IAAI,EAAE,gBAAgB,CAAC,IAAI,IACxB,gBAAgB,EACnB;IACJ,CAAC;CAEF;AAjBD,kDAiBC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { DateOrDateString, ISO8601DateString, Maybe, Minutes, Seconds } from '@dereekb/util';
|
|
2
|
+
export declare const MAX_FUTURE_DATE: Date;
|
|
3
|
+
export declare function msToMinutes(milliseconds: number): Minutes;
|
|
4
|
+
export declare function msToSeconds(milliseconds: number): Seconds;
|
|
5
|
+
export declare function hoursToMs(hours?: number): Minutes;
|
|
6
|
+
export declare function minutesToMs(minutes?: number): Minutes;
|
|
7
|
+
export declare function daysToMinutes(days?: number): Minutes;
|
|
8
|
+
export declare function maxFutureDate(): Date;
|
|
9
|
+
export declare function isMaxFutureDate(date: Date): boolean;
|
|
10
|
+
export declare function latestMinute(time?: Date): Date;
|
|
11
|
+
export declare function toISODateString(input: DateOrDateString): ISO8601DateString;
|
|
12
|
+
export declare function guessCurrentTimezone(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Converts the input DateOrDateString to a Date value.
|
|
15
|
+
*
|
|
16
|
+
* @param input
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare function toJsDate(input: DateOrDateString): Date;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the latest date from the input array.
|
|
22
|
+
*/
|
|
23
|
+
export declare function latestDate(dates: Maybe<Date>[]): Maybe<Date>;
|
|
24
|
+
export declare function latestDate(dates: Maybe<Date>[], defaultDate: Date): Date;
|
|
25
|
+
/**
|
|
26
|
+
* Returns true if a and b are defined and a is after b, otherwise returns the default value.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isAfter(a: Maybe<Date>, b: Maybe<Date>): Maybe<boolean>;
|
|
29
|
+
export declare function isAfter(a: Maybe<Date>, b: Maybe<Date>, defaultValue: boolean): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Converts the input date to represent the "day" represented in the time.
|
|
32
|
+
*
|
|
33
|
+
* For example, 1/1/2021 should be represented as a UTC-offset date for 1/1/2021 for the first instant of the day.
|
|
34
|
+
*/
|
|
35
|
+
export declare function utcDayForDate(date: Date): Date;
|
|
36
|
+
/**
|
|
37
|
+
* Takes the next occuring time of the input date's hours/minutes.
|
|
38
|
+
*
|
|
39
|
+
* For example, if it is currently 9PM:
|
|
40
|
+
* - if 10PM on any day is passed then 9PM the next day will be returned.
|
|
41
|
+
* - if 11PM on any day is passed, 11PM today will be returned.
|
|
42
|
+
*/
|
|
43
|
+
export declare function takeNextUpcomingTime(date: Date, removeSeconds?: boolean): Date;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new date and copies the hours/minutes from the previous date.
|
|
46
|
+
*/
|
|
47
|
+
export declare function copyHoursAndMinutesFromDateToToday(date: Date, removeSeconds?: boolean): Date;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new date and copies the hours/minutes from the input.
|
|
50
|
+
*
|
|
51
|
+
* Also rounds the seconds and milliseconds.
|
|
52
|
+
*/
|
|
53
|
+
export declare function copyHoursAndMinutesToToday({ hours, minutes, removeSeconds }: {
|
|
54
|
+
hours: number;
|
|
55
|
+
minutes?: number;
|
|
56
|
+
removeSeconds?: boolean;
|
|
57
|
+
}): Date;
|
|
58
|
+
/**
|
|
59
|
+
* Removes the seconds and milliseconds from the input date.
|
|
60
|
+
*/
|
|
61
|
+
export declare function roundDownToMinute(date?: Date): Date;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Minutes } from "@dereekb/util";
|
|
2
|
+
import { DateRange, DateRangeState } from "./date.range";
|
|
3
|
+
export declare class DateDurationSpan {
|
|
4
|
+
startsAt: Date;
|
|
5
|
+
duration: Minutes;
|
|
6
|
+
constructor(template: DateDurationSpan);
|
|
7
|
+
}
|
|
8
|
+
export declare function durationSpanToDateRange(span: DateDurationSpan): DateRange;
|
|
9
|
+
export declare function durationSpanDateRangeState(span: DateDurationSpan): DateRangeState;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.durationSpanDateRangeState = exports.durationSpanToDateRange = exports.DateDurationSpan = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const class_transformer_1 = require("class-transformer");
|
|
6
|
+
const date_fns_1 = require("date-fns");
|
|
7
|
+
const date_range_1 = require("./date.range");
|
|
8
|
+
class DateDurationSpan {
|
|
9
|
+
constructor(template) {
|
|
10
|
+
this.startsAt = template.startsAt;
|
|
11
|
+
this.duration = template.duration;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
(0, tslib_1.__decorate)([
|
|
15
|
+
(0, class_transformer_1.Expose)(),
|
|
16
|
+
(0, class_transformer_1.Type)(() => Date),
|
|
17
|
+
(0, tslib_1.__metadata)("design:type", Date)
|
|
18
|
+
], DateDurationSpan.prototype, "startsAt", void 0);
|
|
19
|
+
(0, tslib_1.__decorate)([
|
|
20
|
+
(0, class_transformer_1.Expose)(),
|
|
21
|
+
(0, tslib_1.__metadata)("design:type", Number)
|
|
22
|
+
], DateDurationSpan.prototype, "duration", void 0);
|
|
23
|
+
exports.DateDurationSpan = DateDurationSpan;
|
|
24
|
+
function durationSpanToDateRange(span) {
|
|
25
|
+
return {
|
|
26
|
+
start: span.startsAt,
|
|
27
|
+
end: (0, date_fns_1.addMinutes)(span.startsAt, span.duration)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.durationSpanToDateRange = durationSpanToDateRange;
|
|
31
|
+
function durationSpanDateRangeState(span) {
|
|
32
|
+
return (0, date_range_1.dateRangeState)(durationSpanToDateRange(span));
|
|
33
|
+
}
|
|
34
|
+
exports.durationSpanDateRangeState = durationSpanDateRangeState;
|
|
35
|
+
//# sourceMappingURL=date.duration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.duration.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/date/date.duration.ts"],"names":[],"mappings":";;;;AACA,yDAAiD;AACjD,uCAAsC;AACtC,6CAAyE;AAEzE,MAAa,gBAAgB;IAS3B,YAAY,QAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;IACpC,CAAC;CAEF;AAVC;IAFC,IAAA,0BAAM,GAAE;IACR,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;2CACP,IAAI;kDAAC;AAGf;IADC,IAAA,0BAAM,GAAE;;kDACS;AAPpB,4CAcC;AAED,SAAgB,uBAAuB,CAAC,IAAsB;IAC5D,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,QAAQ;QACpB,GAAG,EAAE,IAAA,qBAAU,EAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC;KAC9C,CAAC;AACJ,CAAC;AALD,0DAKC;AAED,SAAgB,0BAA0B,CAAC,IAAsB;IAC/D,OAAO,IAAA,2BAAc,EAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC;AACvD,CAAC;AAFD,gEAEC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ISO8601DayString } from "@dereekb/util";
|
|
2
|
+
import { DateRange } from "./date.range";
|
|
3
|
+
/**
|
|
4
|
+
* Formats the input to be start - end
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatToTimeRangeString(start: Date, end: Date): string;
|
|
7
|
+
export declare function formatToDateString(date: Date): string;
|
|
8
|
+
export declare function formatToTimeString(date: Date): string;
|
|
9
|
+
export declare function formatToTimeAndDurationString(start: Date, end: Date): string;
|
|
10
|
+
export declare function formatStartedEndedDistanceString({ start, end }: DateRange): string;
|
|
11
|
+
export declare function dateStringToDate(dateString: ISO8601DayString): Date;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dateStringToDate = exports.formatStartedEndedDistanceString = exports.formatToTimeAndDurationString = exports.formatToTimeString = exports.formatToDateString = exports.formatToTimeRangeString = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
const date_range_1 = require("./date.range");
|
|
6
|
+
/**
|
|
7
|
+
* Formats the input to be start - end
|
|
8
|
+
*/
|
|
9
|
+
function formatToTimeRangeString(start, end) {
|
|
10
|
+
return `${formatToTimeString(start)} - ${formatToTimeString(end)}`;
|
|
11
|
+
}
|
|
12
|
+
exports.formatToTimeRangeString = formatToTimeRangeString;
|
|
13
|
+
function formatToDateString(date) {
|
|
14
|
+
return (0, date_fns_1.format)(date, 'EEE, MMM do');
|
|
15
|
+
}
|
|
16
|
+
exports.formatToDateString = formatToDateString;
|
|
17
|
+
function formatToTimeString(date) {
|
|
18
|
+
return (0, date_fns_1.format)(date, 'h:mm a');
|
|
19
|
+
}
|
|
20
|
+
exports.formatToTimeString = formatToTimeString;
|
|
21
|
+
function formatToTimeAndDurationString(start, end) {
|
|
22
|
+
const minutes = (0, date_fns_1.differenceInMinutes)(end, start);
|
|
23
|
+
let subtitle;
|
|
24
|
+
if (minutes > 120) {
|
|
25
|
+
subtitle = `(${(0, date_fns_1.formatDistance)(end, start, { includeSeconds: false })})`;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
subtitle = `${(minutes) ? `(${minutes} Minutes)` : ''}`;
|
|
29
|
+
}
|
|
30
|
+
return `${formatToTimeString(start)} ${subtitle}`;
|
|
31
|
+
}
|
|
32
|
+
exports.formatToTimeAndDurationString = formatToTimeAndDurationString;
|
|
33
|
+
function formatStartedEndedDistanceString({ start, end }) {
|
|
34
|
+
const state = (0, date_range_1.dateRangeState)({ start, end });
|
|
35
|
+
let distanceText;
|
|
36
|
+
switch (state) {
|
|
37
|
+
case date_range_1.DateRangeState.PAST:
|
|
38
|
+
distanceText = `ended ${(0, date_fns_1.formatDistanceToNow)(end, {
|
|
39
|
+
addSuffix: true
|
|
40
|
+
})}`;
|
|
41
|
+
break;
|
|
42
|
+
case date_range_1.DateRangeState.PRESENT:
|
|
43
|
+
distanceText = `started ${(0, date_fns_1.formatDistanceToNow)(start, {
|
|
44
|
+
addSuffix: true
|
|
45
|
+
})}`;
|
|
46
|
+
break;
|
|
47
|
+
case date_range_1.DateRangeState.FUTURE:
|
|
48
|
+
distanceText = `starting ${(0, date_fns_1.formatDistanceToNow)(start, {
|
|
49
|
+
addSuffix: true
|
|
50
|
+
})}`;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
return distanceText;
|
|
54
|
+
}
|
|
55
|
+
exports.formatStartedEndedDistanceString = formatStartedEndedDistanceString;
|
|
56
|
+
function dateStringToDate(dateString) {
|
|
57
|
+
return (0, date_fns_1.startOfDay)((0, date_fns_1.parse)(dateString, 'yyyy-MM-dd', new Date()));
|
|
58
|
+
}
|
|
59
|
+
exports.dateStringToDate = dateStringToDate;
|
|
60
|
+
//# sourceMappingURL=date.format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.format.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/date/date.format.ts"],"names":[],"mappings":";;;AACA,uCAA+G;AAC/G,6CAAyE;AAEzE;;GAEG;AACF,SAAgB,uBAAuB,CAAC,KAAW,EAAE,GAAS;IAC7D,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,MAAM,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;AACrE,CAAC;AAFA,0DAEA;AAED,SAAgB,kBAAkB,CAAC,IAAU;IAC3C,OAAO,IAAA,iBA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B,YAAY,GAAG,YAAY,IAAA,8BAAmB,EAAC,KAAK,EAAE;gBACpD,SAAS,EAAE,IAAI;aAChB,CAAC,EAAE,CAAC;YACL,MAAM;KACT;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAvBD,4EAuBC;AAED,SAAgB,gBAAgB,CAAC,UAA4B;IAC3D,OAAO,IAAA,qBAAU,EAAC,IAAA,gBAAK,EAAC,UAAU,EAAE,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;AACjE,CAAC;AAFD,4CAEC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateSet = void 0;
|
|
4
|
+
const util_1 = require("@dereekb/util");
|
|
5
|
+
class DateSet extends util_1.HashSet {
|
|
6
|
+
constructor(values) {
|
|
7
|
+
super({ readKey: (date) => date.getTime() }, values);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.DateSet = DateSet;
|
|
11
|
+
//# sourceMappingURL=date.hashset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.hashset.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/date/date.hashset.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AAExC,MAAa,OAAQ,SAAQ,cAAqB;IAEhD,YAAY,MAAe;QACzB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;CAEF;AAND,0BAMC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.roundDownToMinute = exports.copyHoursAndMinutesToToday = exports.copyHoursAndMinutesFromDateToToday = exports.takeNextUpcomingTime = exports.utcDayForDate = exports.isAfter = exports.latestDate = exports.toJsDate = exports.guessCurrentTimezone = exports.toISODateString = exports.latestMinute = exports.isMaxFutureDate = exports.maxFutureDate = exports.daysToMinutes = exports.minutesToMs = exports.hoursToMs = exports.msToSeconds = exports.msToMinutes = exports.MAX_FUTURE_DATE = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
const util_1 = require("@dereekb/util");
|
|
6
|
+
exports.MAX_FUTURE_DATE = new Date(Date.UTC(9999, 0));
|
|
7
|
+
function msToMinutes(milliseconds) {
|
|
8
|
+
return milliseconds / (60 * 1000);
|
|
9
|
+
}
|
|
10
|
+
exports.msToMinutes = msToMinutes;
|
|
11
|
+
function msToSeconds(milliseconds) {
|
|
12
|
+
return milliseconds / 1000;
|
|
13
|
+
}
|
|
14
|
+
exports.msToSeconds = msToSeconds;
|
|
15
|
+
function hoursToMs(hours = 1) {
|
|
16
|
+
return hours * util_1.MS_IN_HOUR;
|
|
17
|
+
}
|
|
18
|
+
exports.hoursToMs = hoursToMs;
|
|
19
|
+
function minutesToMs(minutes = 1) {
|
|
20
|
+
return minutes * util_1.MS_IN_MINUTE;
|
|
21
|
+
}
|
|
22
|
+
exports.minutesToMs = minutesToMs;
|
|
23
|
+
function daysToMinutes(days = 1) {
|
|
24
|
+
return days * util_1.MINUTES_IN_DAY;
|
|
25
|
+
}
|
|
26
|
+
exports.daysToMinutes = daysToMinutes;
|
|
27
|
+
function maxFutureDate() {
|
|
28
|
+
return exports.MAX_FUTURE_DATE;
|
|
29
|
+
}
|
|
30
|
+
exports.maxFutureDate = maxFutureDate;
|
|
31
|
+
function isMaxFutureDate(date) {
|
|
32
|
+
return exports.MAX_FUTURE_DATE.getTime() === date.getTime();
|
|
33
|
+
}
|
|
34
|
+
exports.isMaxFutureDate = isMaxFutureDate;
|
|
35
|
+
function latestMinute(time = new Date) {
|
|
36
|
+
return (0, date_fns_1.startOfMinute)(time);
|
|
37
|
+
}
|
|
38
|
+
exports.latestMinute = latestMinute;
|
|
39
|
+
function toISODateString(input) {
|
|
40
|
+
const date = toJsDate(input);
|
|
41
|
+
if (!(0, date_fns_1.isValid)(date)) {
|
|
42
|
+
throw new Error('Invalid date passed.');
|
|
43
|
+
}
|
|
44
|
+
return date.toISOString();
|
|
45
|
+
}
|
|
46
|
+
exports.toISODateString = toISODateString;
|
|
47
|
+
function guessCurrentTimezone() {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
return (_b = (_a = Intl.DateTimeFormat()) === null || _a === void 0 ? void 0 : _a.resolvedOptions()) === null || _b === void 0 ? void 0 : _b.timeZone;
|
|
50
|
+
}
|
|
51
|
+
exports.guessCurrentTimezone = guessCurrentTimezone;
|
|
52
|
+
/**
|
|
53
|
+
* Converts the input DateOrDateString to a Date value.
|
|
54
|
+
*
|
|
55
|
+
* @param input
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
function toJsDate(input) {
|
|
59
|
+
return ((0, date_fns_1.isDate)(input) ? input : (0, date_fns_1.parseISO)(input));
|
|
60
|
+
}
|
|
61
|
+
exports.toJsDate = toJsDate;
|
|
62
|
+
function latestDate(dates, defaultDate = undefined) {
|
|
63
|
+
const filtered = (0, util_1.filterMaybeValues)(dates);
|
|
64
|
+
return (filtered.length > 0) ? (0, date_fns_1.max)(filtered) : undefined;
|
|
65
|
+
}
|
|
66
|
+
exports.latestDate = latestDate;
|
|
67
|
+
function isAfter(a, b, defaultValue = undefined) {
|
|
68
|
+
return (a && b) ? (0, date_fns_1.isAfter)(a, b) : defaultValue;
|
|
69
|
+
}
|
|
70
|
+
exports.isAfter = isAfter;
|
|
71
|
+
// MARK: Unix Date/Time
|
|
72
|
+
/**
|
|
73
|
+
* Converts the input date to represent the "day" represented in the time.
|
|
74
|
+
*
|
|
75
|
+
* For example, 1/1/2021 should be represented as a UTC-offset date for 1/1/2021 for the first instant of the day.
|
|
76
|
+
*/
|
|
77
|
+
function utcDayForDate(date) {
|
|
78
|
+
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
79
|
+
}
|
|
80
|
+
exports.utcDayForDate = utcDayForDate;
|
|
81
|
+
/**
|
|
82
|
+
* Takes the next occuring time of the input date's hours/minutes.
|
|
83
|
+
*
|
|
84
|
+
* For example, if it is currently 9PM:
|
|
85
|
+
* - if 10PM on any day is passed then 9PM the next day will be returned.
|
|
86
|
+
* - if 11PM on any day is passed, 11PM today will be returned.
|
|
87
|
+
*/
|
|
88
|
+
function takeNextUpcomingTime(date, removeSeconds) {
|
|
89
|
+
date = copyHoursAndMinutesFromDateToToday(date, removeSeconds);
|
|
90
|
+
if ((0, date_fns_1.isPast)(date)) {
|
|
91
|
+
date = (0, date_fns_1.addDays)(date, 1);
|
|
92
|
+
}
|
|
93
|
+
return date;
|
|
94
|
+
}
|
|
95
|
+
exports.takeNextUpcomingTime = takeNextUpcomingTime;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a new date and copies the hours/minutes from the previous date.
|
|
98
|
+
*/
|
|
99
|
+
function copyHoursAndMinutesFromDateToToday(date, removeSeconds) {
|
|
100
|
+
return copyHoursAndMinutesToToday({
|
|
101
|
+
hours: date.getHours(),
|
|
102
|
+
minutes: date.getMinutes(),
|
|
103
|
+
removeSeconds
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
exports.copyHoursAndMinutesFromDateToToday = copyHoursAndMinutesFromDateToToday;
|
|
107
|
+
/**
|
|
108
|
+
* Creates a new date and copies the hours/minutes from the input.
|
|
109
|
+
*
|
|
110
|
+
* Also rounds the seconds and milliseconds.
|
|
111
|
+
*/
|
|
112
|
+
function copyHoursAndMinutesToToday({ hours, minutes, removeSeconds = true }) {
|
|
113
|
+
return (0, date_fns_1.set)(new Date(), Object.assign(Object.assign({ hours }, (minutes != null) ? {
|
|
114
|
+
minutes
|
|
115
|
+
} : undefined), (removeSeconds) ? {
|
|
116
|
+
seconds: 0,
|
|
117
|
+
milliseconds: 0
|
|
118
|
+
} : undefined));
|
|
119
|
+
}
|
|
120
|
+
exports.copyHoursAndMinutesToToday = copyHoursAndMinutesToToday;
|
|
121
|
+
/**
|
|
122
|
+
* Removes the seconds and milliseconds from the input date.
|
|
123
|
+
*/
|
|
124
|
+
function roundDownToMinute(date = new Date()) {
|
|
125
|
+
return (0, date_fns_1.set)(date, {
|
|
126
|
+
seconds: 0,
|
|
127
|
+
milliseconds: 0
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
exports.roundDownToMinute = roundDownToMinute;
|
|
131
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../../../packages/date/src/lib/date/date.ts"],"names":[],"mappings":";;;AAAA,uCAEkB;AAClB,wCAA0J;AAE7I,QAAA,eAAe,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAE3D,SAAgB,WAAW,CAAC,YAAoB;IAC9C,OAAO,YAAY,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACpC,CAAC;AAFD,kCAEC;AAED,SAAgB,WAAW,CAAC,YAAoB;IAC9C,OAAO,YAAY,GAAG,IAAI,CAAC;AAC7B,CAAC;AAFD,kCAEC;AAED,SAAgB,SAAS,CAAC,QAAgB,CAAC;IACzC,OAAO,KAAK,GAAG,iBAAU,CAAC;AAC5B,CAAC;AAFD,8BAEC;AAED,SAAgB,WAAW,CAAC,UAAkB,CAAC;IAC7C,OAAO,OAAO,GAAG,mBAAY,CAAC;AAChC,CAAC;AAFD,kCAEC;AAED,SAAgB,aAAa,CAAC,OAAe,CAAC;IAC5C,OAAO,IAAI,GAAG,qBAAc,CAAC;AAC/B,CAAC;AAFD,sCAEC;AAED,SAAgB,aAAa;IAC3B,OAAO,uBAAe,CAAC;AACzB,CAAC;AAFD,sCAEC;AAED,SAAgB,eAAe,CAAC,IAAU;IACxC,OAAO,uBAAe,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC,OAAO,EAA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AAiB,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE;IACjD,OAAO,IAAA,cAAa,EAAC,IAAI,EAAE;QACzB,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,CAAC;KAChB,CAAC,CAAC;AACL,CAAC;AALD,8CAKC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a start and end date.
|
|
3
|
+
*/
|
|
4
|
+
export interface DateRange {
|
|
5
|
+
start: Date;
|
|
6
|
+
end: Date;
|
|
7
|
+
}
|
|
8
|
+
export declare enum DateRangeType {
|
|
9
|
+
/**
|
|
10
|
+
* Includes only the target day.
|
|
11
|
+
*/
|
|
12
|
+
DAY = "day",
|
|
13
|
+
/**
|
|
14
|
+
* Includes only the target week.
|
|
15
|
+
*/
|
|
16
|
+
WEEK = "week",
|
|
17
|
+
/**
|
|
18
|
+
* Includes only the target month.
|
|
19
|
+
*/
|
|
20
|
+
MONTH = "month",
|
|
21
|
+
/**
|
|
22
|
+
* Range specified in hours with the input.
|
|
23
|
+
*/
|
|
24
|
+
HOURS_RANGE = "hours_range",
|
|
25
|
+
/**
|
|
26
|
+
* Range specified in days with the input.
|
|
27
|
+
*/
|
|
28
|
+
DAYS_RANGE = "days_range",
|
|
29
|
+
/**
|
|
30
|
+
* Range specified in weeks with the input.
|
|
31
|
+
*/
|
|
32
|
+
WEEKS_RANGE = "weeks_range",
|
|
33
|
+
/**
|
|
34
|
+
* Radius specified in hours with the input.
|
|
35
|
+
*/
|
|
36
|
+
HOURS_RADIUS = "hours_radius",
|
|
37
|
+
/**
|
|
38
|
+
* Radius specified in days with the input.
|
|
39
|
+
*/
|
|
40
|
+
DAYS_RADIUS = "days_radius",
|
|
41
|
+
/**
|
|
42
|
+
* Radius specified in weeks with the input.
|
|
43
|
+
*/
|
|
44
|
+
WEEKS_RADIUS = "weeks_radius",
|
|
45
|
+
/**
|
|
46
|
+
* Plus/minus 20 hours from the current day.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated design not relevant anymore
|
|
49
|
+
*/
|
|
50
|
+
WITHIN_DAY = "within_day",
|
|
51
|
+
/**
|
|
52
|
+
* Plus/minus 4 days from the current day.
|
|
53
|
+
*
|
|
54
|
+
* @deprecated design not relevant anymore
|
|
55
|
+
*/
|
|
56
|
+
WITHIN_WEEK = "within_week",
|
|
57
|
+
/**
|
|
58
|
+
* Plus/minus 16 days from the current day.
|
|
59
|
+
*
|
|
60
|
+
* @deprecated design not relevant anymore
|
|
61
|
+
*/
|
|
62
|
+
WITHIN_MONTH = "within_month"
|
|
63
|
+
}
|
|
64
|
+
export declare enum DateRangeState {
|
|
65
|
+
/**
|
|
66
|
+
* Range has yet to start and is in the future.
|
|
67
|
+
*/
|
|
68
|
+
FUTURE = "future",
|
|
69
|
+
/**
|
|
70
|
+
* Range is in the present, but not yet ended.
|
|
71
|
+
*/
|
|
72
|
+
PRESENT = "present",
|
|
73
|
+
/**
|
|
74
|
+
* Range is in the past.
|
|
75
|
+
*/
|
|
76
|
+
PAST = "past"
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Params for building a date range.
|
|
80
|
+
*/
|
|
81
|
+
export declare class DateRangeParams {
|
|
82
|
+
/**
|
|
83
|
+
* Type of range.
|
|
84
|
+
*/
|
|
85
|
+
type: DateRangeType;
|
|
86
|
+
/**
|
|
87
|
+
* Date to filter on. If not provided, assumes now.
|
|
88
|
+
*/
|
|
89
|
+
date?: Date;
|
|
90
|
+
distance?: number;
|
|
91
|
+
constructor(template: DateRangeParams);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Creates a DateRange from the input DateRangeParams
|
|
95
|
+
*
|
|
96
|
+
* @param param0
|
|
97
|
+
* @param roundToMinute
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
export declare function makeDateRange({ type, date, distance }: DateRangeParams, roundToMinute?: boolean): DateRange;
|
|
101
|
+
/**
|
|
102
|
+
* Returns the DateRangeState from the input DateRange.
|
|
103
|
+
*
|
|
104
|
+
* @param param0
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
export declare function dateRangeState({ start, end }: DateRange): DateRangeState;
|