@tsdotnet/date-time 1.1.0 → 1.1.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/dist/cjs/ClockTime.js +13 -18
- package/dist/cjs/ClockTime.js.map +1 -1
- package/dist/cjs/DateTime.js +9 -96
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/TimeQuantity.js +10 -43
- package/dist/cjs/TimeQuantity.js.map +1 -1
- package/dist/cjs/TimeSpan.js +5 -30
- package/dist/cjs/TimeSpan.js.map +1 -1
- package/dist/cjs/TimeStamp.js +1 -6
- package/dist/cjs/TimeStamp.js.map +1 -1
- package/dist/cjs/TimeUnit.js +11 -40
- package/dist/cjs/TimeUnit.js.map +1 -1
- package/dist/cjs/TimeUnitValue.js +0 -4
- package/dist/cjs/TimeUnitValue.js.map +1 -1
- package/dist/cjs/howMany.js +0 -46
- package/dist/cjs/howMany.js.map +1 -1
- package/dist/esm/ClockTime.js +19 -22
- package/dist/esm/ClockTime.js.map +1 -1
- package/dist/esm/DateTime.js +18 -102
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/TimeQuantity.js +19 -49
- package/dist/esm/TimeQuantity.js.map +1 -1
- package/dist/esm/TimeSpan.js +15 -56
- package/dist/esm/TimeSpan.js.map +1 -1
- package/dist/esm/TimeStamp.js +7 -10
- package/dist/esm/TimeStamp.js.map +1 -1
- package/dist/esm/TimeUnit.js +16 -43
- package/dist/esm/TimeUnit.js.map +1 -1
- package/dist/esm/TimeUnitValue.js +7 -8
- package/dist/esm/TimeUnitValue.js.map +1 -1
- package/dist/esm/date-time.js +10 -14
- package/dist/esm/date-time.js.map +1 -1
- package/dist/esm/howMany.js +1 -46
- package/dist/esm/howMany.js.map +1 -1
- package/dist/types/Calendars/Gregorian.d.ts +37 -0
- package/dist/types/DateTime.d.ts +60 -0
- package/dist/types/TimeQuantity.d.ts +19 -0
- package/dist/{TimeSpan.d.ts → types/TimeSpan.d.ts} +0 -40
- package/dist/{TimeStamp.d.ts → types/TimeStamp.d.ts} +0 -3
- package/dist/types/TimeUnit.d.ts +21 -0
- package/dist/{TimeUnitValue.d.ts → types/TimeUnitValue.d.ts} +0 -3
- package/dist/{howMany.d.ts → types/howMany.d.ts} +5 -5
- package/package.json +87 -97
- package/rollup.config.js +37 -0
- package/dist/Calendars/Gregorian.d.ts +0 -30
- package/dist/DateTime.d.ts +0 -154
- package/dist/TimeQuantity.d.ts +0 -50
- package/dist/TimeUnit.d.ts +0 -47
- package/dist/cjs/Calendars/Gregorian.js +0 -7
- package/dist/cjs/Calendars/Gregorian.js.map +0 -1
- package/dist/esm/Calendars/Gregorian.js +0 -6
- package/dist/esm/Calendars/Gregorian.js.map +0 -1
- package/dist/esm/DateTimeKind.js +0 -6
- package/dist/esm/DateTimeKind.js.map +0 -1
- package/dist/umd/Calendars/Gregorian.js +0 -17
- package/dist/umd/Calendars/Gregorian.js.map +0 -1
- package/dist/umd/ClockTime.js +0 -86
- package/dist/umd/ClockTime.js.map +0 -1
- package/dist/umd/DateTime.js +0 -320
- package/dist/umd/DateTime.js.map +0 -1
- package/dist/umd/DateTimeKind.js +0 -17
- package/dist/umd/DateTimeKind.js.map +0 -1
- package/dist/umd/TimeQuantity.js +0 -108
- package/dist/umd/TimeQuantity.js.map +0 -1
- package/dist/umd/TimeSpan.js +0 -148
- package/dist/umd/TimeSpan.js.map +0 -1
- package/dist/umd/TimeStamp.js +0 -65
- package/dist/umd/TimeStamp.js.map +0 -1
- package/dist/umd/TimeUnit.js +0 -111
- package/dist/umd/TimeUnit.js.map +0 -1
- package/dist/umd/TimeUnitValue.js +0 -58
- package/dist/umd/TimeUnitValue.js.map +0 -1
- package/dist/umd/date-time.js +0 -35
- package/dist/umd/date-time.js.map +0 -1
- package/dist/umd/howMany.js +0 -63
- package/dist/umd/howMany.js.map +0 -1
- /package/dist/{CalendarDate.d.ts → types/CalendarDate.d.ts} +0 -0
- /package/dist/{ClockTime.d.ts → types/ClockTime.d.ts} +0 -0
- /package/dist/{ClockTimeValue.d.ts → types/ClockTimeValue.d.ts} +0 -0
- /package/dist/{DateTimeKind.d.ts → types/DateTimeKind.d.ts} +0 -0
- /package/dist/{JsDateConvertible.d.ts → types/JsDateConvertible.d.ts} +0 -0
- /package/dist/{TimeMeasurement.d.ts → types/TimeMeasurement.d.ts} +0 -0
- /package/dist/{TimeStampValue.d.ts → types/TimeStampValue.d.ts} +0 -0
- /package/dist/{date-time.d.ts → types/date-time.d.ts} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @author electricessence / https://github.com/electricessence/
|
|
3
|
+
* Based on .NET DateTime's interface.
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
import CalendarDate from './CalendarDate';
|
|
7
|
+
import Gregorian from './Calendars/Gregorian';
|
|
8
|
+
import ClockTime from './ClockTime';
|
|
9
|
+
import DateTimeKind from './DateTimeKind';
|
|
10
|
+
import type JsDateConvertible from './JsDateConvertible';
|
|
11
|
+
import TimeQuantity from './TimeQuantity';
|
|
12
|
+
import TimeSpan from './TimeSpan';
|
|
13
|
+
import TimeStamp from './TimeStamp';
|
|
14
|
+
export default class DateTime implements CalendarDate, JsDateConvertible {
|
|
15
|
+
private readonly _value;
|
|
16
|
+
private readonly _kind;
|
|
17
|
+
private _time;
|
|
18
|
+
constructor();
|
|
19
|
+
constructor(dateString: string, kind?: DateTimeKind);
|
|
20
|
+
constructor(milliseconds: number, kind?: DateTimeKind);
|
|
21
|
+
constructor(source: Date, kind?: DateTimeKind);
|
|
22
|
+
constructor(source: DateTime, kind?: DateTimeKind);
|
|
23
|
+
static get now(): DateTime;
|
|
24
|
+
static get today(): DateTime;
|
|
25
|
+
static get tomorrow(): DateTime;
|
|
26
|
+
get kind(): DateTimeKind;
|
|
27
|
+
get year(): number;
|
|
28
|
+
get month(): Gregorian.Month;
|
|
29
|
+
get calendarMonth(): number;
|
|
30
|
+
get calendar(): CalendarDate;
|
|
31
|
+
get day(): number;
|
|
32
|
+
get dayIndex(): number;
|
|
33
|
+
get dayOfWeek(): Gregorian.DayOfWeek;
|
|
34
|
+
get date(): DateTime;
|
|
35
|
+
get timeOfDay(): ClockTime;
|
|
36
|
+
static between(first: Date | DateTime, last: Date | DateTime): TimeSpan;
|
|
37
|
+
static isLeapYear(year: number): boolean;
|
|
38
|
+
static daysInMonth(year: number, month: Gregorian.Month): number;
|
|
39
|
+
static from(calendarDate: CalendarDate): DateTime;
|
|
40
|
+
static from(year: number, month: Gregorian.Month, day: number): DateTime;
|
|
41
|
+
static fromCalendarDate(calendarDate: CalendarDate): DateTime;
|
|
42
|
+
static fromCalendarDate(year: number, month: number, day: number): DateTime;
|
|
43
|
+
toJsDate(): Date;
|
|
44
|
+
addMilliseconds(ms: number): DateTime;
|
|
45
|
+
addSeconds(seconds: number): DateTime;
|
|
46
|
+
addMinutes(minutes: number): DateTime;
|
|
47
|
+
addHours(hours: number): DateTime;
|
|
48
|
+
addDays(days: number): DateTime;
|
|
49
|
+
addMonths(months: number): DateTime;
|
|
50
|
+
addYears(years: number): DateTime;
|
|
51
|
+
add(time: TimeQuantity): DateTime;
|
|
52
|
+
subtract(time: TimeQuantity): DateTime;
|
|
53
|
+
timePassedSince(previous: Date | DateTime): TimeSpan;
|
|
54
|
+
toTimeStamp(): TimeStamp;
|
|
55
|
+
toUniversalTime(): DateTime;
|
|
56
|
+
equals(other: Date): boolean;
|
|
57
|
+
equals(other: JsDateConvertible, strict?: boolean): boolean;
|
|
58
|
+
compareTo(other: Date | JsDateConvertible): number;
|
|
59
|
+
equivalent(other: Date | JsDateConvertible): boolean;
|
|
60
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @author electricessence / https://github.com/electricessence/
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
import { ResettableLazy } from '@tsdotnet/lazy';
|
|
6
|
+
import type TimeMeasurement from './TimeMeasurement';
|
|
7
|
+
import TimeUnit from './TimeUnit';
|
|
8
|
+
export default class TimeQuantity {
|
|
9
|
+
protected _quantity: number;
|
|
10
|
+
constructor(_quantity?: number);
|
|
11
|
+
static getTotalMillisecondsFrom(values: Partial<TimeMeasurement>): number;
|
|
12
|
+
get direction(): number;
|
|
13
|
+
protected _total: ResettableLazy<Readonly<TimeMeasurement>>;
|
|
14
|
+
get total(): Readonly<TimeMeasurement>;
|
|
15
|
+
getTotalMilliseconds(): number;
|
|
16
|
+
equals(other: TimeQuantity): boolean;
|
|
17
|
+
compareTo(other: TimeQuantity): number;
|
|
18
|
+
getTotal(units: TimeUnit.UnitType): number;
|
|
19
|
+
}
|
|
@@ -7,46 +7,17 @@ import ClockTime from './ClockTime';
|
|
|
7
7
|
import TimeMeasurement from './TimeMeasurement';
|
|
8
8
|
import TimeQuantity from './TimeQuantity';
|
|
9
9
|
import TimeUnit from './TimeUnit';
|
|
10
|
-
/**
|
|
11
|
-
* TimeSpan expands on TimeQuantity to provide an class that is similar to .NET's TimeSpan including many useful static methods.
|
|
12
|
-
*/
|
|
13
10
|
export declare class TimeSpan extends TimeQuantity implements TimeMeasurement {
|
|
14
|
-
/**
|
|
15
|
-
* The total number of ticks that represent this amount of time.
|
|
16
|
-
*/
|
|
17
11
|
readonly ticks: number;
|
|
18
|
-
/**
|
|
19
|
-
* The total number of ticks that milliseconds this amount of time.
|
|
20
|
-
*/
|
|
21
12
|
readonly milliseconds: number;
|
|
22
|
-
/**
|
|
23
|
-
* The total number of ticks that seconds this amount of time.
|
|
24
|
-
*/
|
|
25
13
|
readonly seconds: number;
|
|
26
|
-
/**
|
|
27
|
-
* The total number of ticks that minutes this amount of time.
|
|
28
|
-
*/
|
|
29
14
|
readonly minutes: number;
|
|
30
|
-
/**
|
|
31
|
-
* The total number of ticks that hours this amount of time.
|
|
32
|
-
*/
|
|
33
15
|
readonly hours: number;
|
|
34
|
-
/**
|
|
35
|
-
* The total number of ticks that days this amount of time.
|
|
36
|
-
*/
|
|
37
16
|
readonly days: number;
|
|
38
17
|
protected constructor(value: number, units?: TimeUnit.UnitType);
|
|
39
18
|
static get zero(): TimeSpan;
|
|
40
|
-
/**
|
|
41
|
-
* Provides an standard interface for acquiring the total time.
|
|
42
|
-
* @returns {TimeSpan}
|
|
43
|
-
*/
|
|
44
19
|
get total(): TimeSpan;
|
|
45
20
|
private _time;
|
|
46
|
-
/**
|
|
47
|
-
* The value of this TimeSpan reduced to the clock and calendar.
|
|
48
|
-
* @return {ClockTime}
|
|
49
|
-
*/
|
|
50
21
|
get time(): ClockTime;
|
|
51
22
|
static from(values: Partial<TimeMeasurement>): TimeSpan;
|
|
52
23
|
static from(value: number, units: TimeUnit.UnitType): TimeSpan;
|
|
@@ -56,18 +27,7 @@ export declare class TimeSpan extends TimeQuantity implements TimeMeasurement {
|
|
|
56
27
|
static fromSeconds(value: number): TimeSpan;
|
|
57
28
|
static fromMilliseconds(value: number): TimeSpan;
|
|
58
29
|
static fromTicks(value: number): TimeSpan;
|
|
59
|
-
/**
|
|
60
|
-
* Sum the value of this TimeSpan with another time quantity.
|
|
61
|
-
* @param {TimeQuantity | Partial<TimeMeasurement>} other
|
|
62
|
-
* @return {TimeSpan}
|
|
63
|
-
*/
|
|
64
30
|
add(other: TimeSpan | TimeQuantity | Partial<TimeMeasurement>): TimeSpan;
|
|
65
|
-
/**
|
|
66
|
-
* Sum the value of this TimeSpan with another unit value.
|
|
67
|
-
* @param {number} value
|
|
68
|
-
* @param {TimeUnit.UnitType} units
|
|
69
|
-
* @return {TimeSpan}
|
|
70
|
-
*/
|
|
71
31
|
addUnit(value: number, units?: TimeUnit.UnitType): TimeSpan;
|
|
72
32
|
}
|
|
73
33
|
export default TimeSpan;
|
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
import Gregorian from './Calendars/Gregorian';
|
|
6
6
|
import JsDateConvertible from './JsDateConvertible';
|
|
7
7
|
import TimeStampValue from './TimeStampValue';
|
|
8
|
-
/**
|
|
9
|
-
* An alternative to Date or DateTime. Is a model representing the exact date and time.
|
|
10
|
-
*/
|
|
11
8
|
export declare class TimeStamp implements Required<TimeStampValue>, JsDateConvertible {
|
|
12
9
|
readonly year: number;
|
|
13
10
|
readonly month: Gregorian.Month;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @author electricessence / https://github.com/electricessence/
|
|
3
|
+
* Originally based upon .NET source but with many additions and improvements.
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
import TimeQuantity from './TimeQuantity';
|
|
7
|
+
export declare namespace TimeUnit {
|
|
8
|
+
enum UnitType {
|
|
9
|
+
Ticks = 0,
|
|
10
|
+
Milliseconds = 1,
|
|
11
|
+
Seconds = 2,
|
|
12
|
+
Minutes = 3,
|
|
13
|
+
Hours = 4,
|
|
14
|
+
Days = 5
|
|
15
|
+
}
|
|
16
|
+
function toMilliseconds(value: number, units: UnitType): number;
|
|
17
|
+
function fromMilliseconds(ms: number, units: UnitType): number;
|
|
18
|
+
function from(quantity: TimeQuantity, toUnits: UnitType): number;
|
|
19
|
+
function assertValid(unit: UnitType): true | never;
|
|
20
|
+
}
|
|
21
|
+
export default TimeUnit;
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import TimeQuantity from './TimeQuantity';
|
|
6
6
|
import TimeUnit from './TimeUnit';
|
|
7
|
-
/**
|
|
8
|
-
* TimeUnitValue allows for passing around a reference to a mutable measure of time coerced by its unit type.
|
|
9
|
-
*/
|
|
10
7
|
export default class TimeUnitValue extends TimeQuantity {
|
|
11
8
|
private _units;
|
|
12
9
|
constructor(value: number | TimeQuantity, _units: TimeUnit.UnitType);
|
|
@@ -3,25 +3,25 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
export declare namespace hours {
|
|
6
|
-
enum per {
|
|
6
|
+
const enum per {
|
|
7
7
|
day = 24
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
export declare namespace minutes {
|
|
11
|
-
enum per {
|
|
11
|
+
const enum per {
|
|
12
12
|
hour = 60,
|
|
13
13
|
day = 1440
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
export declare namespace seconds {
|
|
17
|
-
enum per {
|
|
17
|
+
const enum per {
|
|
18
18
|
minute = 60,
|
|
19
19
|
hour = 3600,
|
|
20
20
|
day = 86400
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
export declare namespace milliseconds {
|
|
24
|
-
enum per {
|
|
24
|
+
const enum per {
|
|
25
25
|
second = 1000,
|
|
26
26
|
minute = 60000,
|
|
27
27
|
hour = 3600000,
|
|
@@ -29,7 +29,7 @@ export declare namespace milliseconds {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
export declare namespace ticks {
|
|
32
|
-
enum per {
|
|
32
|
+
const enum per {
|
|
33
33
|
millisecond = 10000,
|
|
34
34
|
second = 10000000,
|
|
35
35
|
minute = 600000000,
|
package/package.json
CHANGED
|
@@ -1,97 +1,87 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tsdotnet/date-time",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "",
|
|
5
|
-
"author": "electricessence",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
29
|
-
"build
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"url": "
|
|
46
|
-
},
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"@
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"semver@>=7.0.0 <7.5.2": ">=7.5.2",
|
|
89
|
-
"get-func-name@<2.0.1": ">=2.0.1",
|
|
90
|
-
"@babel/traverse@<7.23.2": ">=7.23.2",
|
|
91
|
-
"braces@<3.0.3": ">=3.0.3"
|
|
92
|
-
},
|
|
93
|
-
"ignoredBuiltDependencies": [
|
|
94
|
-
"esbuild"
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsdotnet/date-time",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "electricessence",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/date-time.d.ts",
|
|
11
|
+
"import": "./dist/esm/date-time.js",
|
|
12
|
+
"require": "./dist/cjs/date-time.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"types": "./dist/types/date-time.d.ts",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"dispose",
|
|
18
|
+
"disposal",
|
|
19
|
+
"disposable",
|
|
20
|
+
"IDisposable",
|
|
21
|
+
"DisposableBase",
|
|
22
|
+
"ObjectDisposedException"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"clean": "rimraf dist",
|
|
26
|
+
"build:types": "cpy \"src/**/*.d.ts\" dist/types --parents && tsc -p tsconfig.types.json",
|
|
27
|
+
"build:esm": "rollup -c rollup.config.js",
|
|
28
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
29
|
+
"build": "pnpm clean && pnpm build:types && pnpm build:esm && pnpm build:cjs",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint src/**/*.ts",
|
|
33
|
+
"docs": "rimraf docs && typedoc --options typedoc.json --readme none",
|
|
34
|
+
"bump": "pnpm run precommit && pnpm version patch",
|
|
35
|
+
"precommit": "pnpm build && pnpm test && pnpm lint && git status -s",
|
|
36
|
+
"preversion": "pnpm lint && pnpm test",
|
|
37
|
+
"postversion": "git push && git push --tags && pnpm run docs && git add -A && git commit -m \"Updated docs.\" docs && git push",
|
|
38
|
+
"prepublishOnly": "pnpm build && pnpm test && pnpm lint"
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/tsdotnet/date-time.git"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/tsdotnet/date-time/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/tsdotnet/date-time#readme",
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@eslint/js": "^9.33.0",
|
|
50
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
51
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
52
|
+
"@types/node": "^24.3.0",
|
|
53
|
+
"cpy-cli": "^6.0.0",
|
|
54
|
+
"eslint": "^9.33.0",
|
|
55
|
+
"rimraf": "^6.0.1",
|
|
56
|
+
"rollup": "^4.46.3",
|
|
57
|
+
"typedoc": "^0.28.10",
|
|
58
|
+
"typescript": "^5.9.2",
|
|
59
|
+
"typescript-eslint": "^8.39.1",
|
|
60
|
+
"vitest": "^3.2.4"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@tsdotnet/compare": "^1.5.4",
|
|
64
|
+
"@tsdotnet/exceptions": "^1.2.4",
|
|
65
|
+
"@tsdotnet/lazy": "^1.1.2",
|
|
66
|
+
"@tsdotnet/type": "^1.2.4",
|
|
67
|
+
"tslib": "^2.8.1"
|
|
68
|
+
},
|
|
69
|
+
"pnpm": {
|
|
70
|
+
"overrides": {
|
|
71
|
+
"hosted-git-info@<2.8.9": ">=2.8.9",
|
|
72
|
+
"y18n@=4.0.0": ">=4.0.1",
|
|
73
|
+
"lodash@<4.17.20": ">=4.17.20",
|
|
74
|
+
"shell-quote@<=1.7.2": ">=1.7.3",
|
|
75
|
+
"lodash@<4.17.21": ">=4.17.21",
|
|
76
|
+
"json5@<1.0.2": ">=1.0.2",
|
|
77
|
+
"json5@>=2.0.0 <2.2.2": ">=2.2.2",
|
|
78
|
+
"minimatch@<3.0.5": ">=3.0.5",
|
|
79
|
+
"semver@<5.7.2": ">=5.7.2",
|
|
80
|
+
"semver@>=6.0.0 <6.3.1": ">=6.3.1",
|
|
81
|
+
"semver@>=7.0.0 <7.5.2": ">=7.5.2",
|
|
82
|
+
"get-func-name@<2.0.1": ">=2.0.1",
|
|
83
|
+
"@babel/traverse@<7.23.2": ">=7.23.2",
|
|
84
|
+
"braces@<3.0.3": ">=3.0.3"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineConfig } from 'rollup';
|
|
2
|
+
import typescript from '@rollup/plugin-typescript';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
|
|
5
|
+
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url)));
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
input: 'src/date-time.ts', // Just use the main entry point
|
|
9
|
+
output: {
|
|
10
|
+
dir: 'dist/esm',
|
|
11
|
+
format: 'es',
|
|
12
|
+
preserveModules: true, // This will automatically include all imported files!
|
|
13
|
+
preserveModulesRoot: 'src',
|
|
14
|
+
entryFileNames: '[name].js',
|
|
15
|
+
sourcemap: true
|
|
16
|
+
},
|
|
17
|
+
external: [
|
|
18
|
+
// Node core modules
|
|
19
|
+
/^node:/,
|
|
20
|
+
// All dependencies and peer dependencies
|
|
21
|
+
...Object.keys(pkg.dependencies || {}),
|
|
22
|
+
...Object.keys(pkg.peerDependencies || {})
|
|
23
|
+
],
|
|
24
|
+
plugins: [
|
|
25
|
+
typescript({
|
|
26
|
+
tsconfig: './tsconfig.esm.json',
|
|
27
|
+
declaration: false, // Keep your existing types build
|
|
28
|
+
declarationMap: false,
|
|
29
|
+
sourceMap: true,
|
|
30
|
+
removeComments: true // Explicitly remove source comments
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @author electricessence / https://github.com/electricessence/
|
|
3
|
-
* @license MIT
|
|
4
|
-
*/
|
|
5
|
-
declare namespace Gregorian {
|
|
6
|
-
const enum Month {
|
|
7
|
-
January = 0,
|
|
8
|
-
February = 1,
|
|
9
|
-
March = 2,
|
|
10
|
-
April = 3,
|
|
11
|
-
May = 4,
|
|
12
|
-
June = 5,
|
|
13
|
-
July = 6,
|
|
14
|
-
August = 7,
|
|
15
|
-
September = 8,
|
|
16
|
-
October = 9,
|
|
17
|
-
November = 10,
|
|
18
|
-
December = 11
|
|
19
|
-
}
|
|
20
|
-
const enum DayOfWeek {
|
|
21
|
-
Sunday = 0,
|
|
22
|
-
Monday = 1,
|
|
23
|
-
Tuesday = 2,
|
|
24
|
-
Wednesday = 3,
|
|
25
|
-
Thursday = 4,
|
|
26
|
-
Friday = 5,
|
|
27
|
-
Saturday = 6
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export default Gregorian;
|
package/dist/DateTime.d.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @author electricessence / https://github.com/electricessence/
|
|
3
|
-
* Based on .NET DateTime's interface.
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
import CalendarDate from './CalendarDate';
|
|
7
|
-
import Gregorian from './Calendars/Gregorian';
|
|
8
|
-
import ClockTime from './ClockTime';
|
|
9
|
-
import DateTimeKind from './DateTimeKind';
|
|
10
|
-
import type JsDateConvertible from './JsDateConvertible';
|
|
11
|
-
import TimeQuantity from './TimeQuantity';
|
|
12
|
-
import TimeSpan from './TimeSpan';
|
|
13
|
-
import TimeStamp from './TimeStamp';
|
|
14
|
-
export default class DateTime implements CalendarDate, JsDateConvertible {
|
|
15
|
-
private readonly _value;
|
|
16
|
-
private readonly _kind;
|
|
17
|
-
private _time;
|
|
18
|
-
constructor();
|
|
19
|
-
constructor(dateString: string, kind?: DateTimeKind);
|
|
20
|
-
constructor(milliseconds: number, kind?: DateTimeKind);
|
|
21
|
-
constructor(source: Date, kind?: DateTimeKind);
|
|
22
|
-
constructor(source: DateTime, kind?: DateTimeKind);
|
|
23
|
-
/**
|
|
24
|
-
* Returns the now local time.
|
|
25
|
-
* @returns {DateTime}
|
|
26
|
-
*/
|
|
27
|
-
static get now(): DateTime;
|
|
28
|
-
/**
|
|
29
|
-
* The date component for now.
|
|
30
|
-
* @returns {DateTime}
|
|
31
|
-
*/
|
|
32
|
-
static get today(): DateTime;
|
|
33
|
-
/**
|
|
34
|
-
* Midnight tomorrow.
|
|
35
|
-
* @returns {DateTime}
|
|
36
|
-
*/
|
|
37
|
-
static get tomorrow(): DateTime;
|
|
38
|
-
get kind(): DateTimeKind;
|
|
39
|
-
get year(): number;
|
|
40
|
-
/**
|
|
41
|
-
* Returns the Gregorian Month (zero indexed).
|
|
42
|
-
* @returns {number}
|
|
43
|
-
*/
|
|
44
|
-
get month(): Gregorian.Month;
|
|
45
|
-
/**
|
|
46
|
-
* Returns the month number (1-12).
|
|
47
|
-
* @returns {number}
|
|
48
|
-
*/
|
|
49
|
-
get calendarMonth(): number;
|
|
50
|
-
get calendar(): CalendarDate;
|
|
51
|
-
/**
|
|
52
|
-
* Returns the day of the month. An integer between 1 and 31.
|
|
53
|
-
* @returns {number}
|
|
54
|
-
*/
|
|
55
|
-
get day(): number;
|
|
56
|
-
/**
|
|
57
|
-
* Returns the day of the month indexed starting at zero.
|
|
58
|
-
* @returns {number}
|
|
59
|
-
*/
|
|
60
|
-
get dayIndex(): number;
|
|
61
|
-
/**
|
|
62
|
-
* Returns the zero indexed day of the week. (Sunday == 0)
|
|
63
|
-
* @returns {number}
|
|
64
|
-
*/
|
|
65
|
-
get dayOfWeek(): Gregorian.DayOfWeek;
|
|
66
|
-
/**
|
|
67
|
-
* Returns a DateTime object for 00:00 of this date.
|
|
68
|
-
*/
|
|
69
|
-
get date(): DateTime;
|
|
70
|
-
/**
|
|
71
|
-
* Returns the time of day represented by a ClockTime object.
|
|
72
|
-
* @returns {ClockTime}
|
|
73
|
-
*/
|
|
74
|
-
get timeOfDay(): ClockTime;
|
|
75
|
-
/**
|
|
76
|
-
* Measures the difference between two dates as a TimeSpan.
|
|
77
|
-
* @param first
|
|
78
|
-
* @param last
|
|
79
|
-
*/
|
|
80
|
-
static between(first: Date | DateTime, last: Date | DateTime): TimeSpan;
|
|
81
|
-
/**
|
|
82
|
-
* Calculates if the given year is a leap year using the formula:
|
|
83
|
-
* ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)
|
|
84
|
-
* @param year
|
|
85
|
-
* @returns {boolean}
|
|
86
|
-
*/
|
|
87
|
-
static isLeapYear(year: number): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Returns the number of days for the specific year and month.
|
|
90
|
-
* @param year
|
|
91
|
-
* @param month
|
|
92
|
-
* @returns {any}
|
|
93
|
-
*/
|
|
94
|
-
static daysInMonth(year: number, month: Gregorian.Month): number;
|
|
95
|
-
static from(calendarDate: CalendarDate): DateTime;
|
|
96
|
-
static from(year: number, month: Gregorian.Month, day: number): DateTime;
|
|
97
|
-
static fromCalendarDate(calendarDate: CalendarDate): DateTime;
|
|
98
|
-
static fromCalendarDate(year: number, month: number, day: number): DateTime;
|
|
99
|
-
toJsDate(): Date;
|
|
100
|
-
addMilliseconds(ms: number): DateTime;
|
|
101
|
-
addSeconds(seconds: number): DateTime;
|
|
102
|
-
addMinutes(minutes: number): DateTime;
|
|
103
|
-
addHours(hours: number): DateTime;
|
|
104
|
-
addDays(days: number): DateTime;
|
|
105
|
-
addMonths(months: number): DateTime;
|
|
106
|
-
addYears(years: number): DateTime;
|
|
107
|
-
/**
|
|
108
|
-
* Receives an TimeQuantity value and adds based on the total milliseconds.
|
|
109
|
-
* @param {TimeQuantity} time
|
|
110
|
-
* @returns {DateTime}
|
|
111
|
-
*/
|
|
112
|
-
add(time: TimeQuantity): DateTime;
|
|
113
|
-
/**
|
|
114
|
-
* Receives an TimeQuantity value and subtracts based on the total milliseconds.
|
|
115
|
-
* @param {TimeQuantity} time
|
|
116
|
-
* @returns {DateTime}
|
|
117
|
-
*/
|
|
118
|
-
subtract(time: TimeQuantity): DateTime;
|
|
119
|
-
/**
|
|
120
|
-
* Returns a TimeSpan representing the amount of time between two dates.
|
|
121
|
-
* @param previous
|
|
122
|
-
* @returns {TimeSpan}
|
|
123
|
-
*/
|
|
124
|
-
timePassedSince(previous: Date | DateTime): TimeSpan;
|
|
125
|
-
/**
|
|
126
|
-
* Returns a readonly object which contains all the date and time components.
|
|
127
|
-
*/
|
|
128
|
-
toTimeStamp(): TimeStamp;
|
|
129
|
-
/**
|
|
130
|
-
* Returns a UTC version of this date if its kind is local.
|
|
131
|
-
* @returns {DateTime}
|
|
132
|
-
*/
|
|
133
|
-
toUniversalTime(): DateTime;
|
|
134
|
-
/**
|
|
135
|
-
* Compares a JS Date with the current instance. Does not evaluate the kind.
|
|
136
|
-
* @param other
|
|
137
|
-
* @returns {boolean}
|
|
138
|
-
*/
|
|
139
|
-
equals(other: Date): boolean;
|
|
140
|
-
/**
|
|
141
|
-
* Compares another JsDateConvertible object and returns true if they or their value are equal.
|
|
142
|
-
* @param other The other JsDateConvertible object.
|
|
143
|
-
* @param strict When strict is true, the 'kind' also must match.
|
|
144
|
-
* @returns {boolean}
|
|
145
|
-
*/
|
|
146
|
-
equals(other: JsDateConvertible, strict?: boolean): boolean;
|
|
147
|
-
compareTo(other: Date | JsDateConvertible): number;
|
|
148
|
-
/**
|
|
149
|
-
* Returns true if the value is the same UTC time.
|
|
150
|
-
* @param {Date | JsDateConvertible} other
|
|
151
|
-
* @return {boolean}
|
|
152
|
-
*/
|
|
153
|
-
equivalent(other: Date | JsDateConvertible): boolean;
|
|
154
|
-
}
|