@@ -8,22 +8,140 @@ export class SonicDate extends Date {
88 }
99}
1010export interface SonicDate {
11+ /**
12+ * Create a new `SonicDate` instance with the same time value.
13+ * @returns A cloned `SonicDate`.
14+ */
1115 clone ( ) : SonicDate ;
16+
17+ /**
18+ * Returns true if this date is after the given date.
19+ * @param dateToCompare - Date, timestamp or ISO string to compare against.
20+ * @returns `true` when this date > `dateToCompare`.
21+ */
1222 isAfter ( dateToCompare : Dateable ) : boolean ;
23+
24+ /**
25+ * Returns true if this date is before the given date.
26+ * @param dateToCompare - Date, timestamp or ISO string to compare against.
27+ * @returns `true` when this date < `dateToCompare`.
28+ */
1329 isBefore ( dateToCompare : Dateable ) : boolean ;
30+
31+ /**
32+ * Add milliseconds to this date (mutates) and return `this`.
33+ * @param amount - Milliseconds to add (may be negative).
34+ * @returns The mutated `SonicDate` instance.
35+ */
1436 addMilliseconds ( amount : number ) : this;
37+
38+ /**
39+ * Add seconds to this date (mutates) and return `this`.
40+ * @param amount - Seconds to add (may be negative).
41+ * @returns The mutated `SonicDate` instance.
42+ */
1543 addSeconds ( amount : number ) : this;
44+
45+ /**
46+ * Add minutes to this date (mutates) and return `this`.
47+ * @param amount - Minutes to add (may be negative).
48+ * @returns The mutated `SonicDate` instance.
49+ */
1650 addMinutes ( amount : number ) : this;
51+
52+ /**
53+ * Add hours to this date (mutates) and return `this`.
54+ * @param amount - Hours to add (may be negative).
55+ * @returns The mutated `SonicDate` instance.
56+ */
1757 addHours ( amount : number ) : this;
58+
59+ /**
60+ * Add days to this date (mutates) and return `this`.
61+ * @param amount - Days to add (may be negative).
62+ * @returns The mutated `SonicDate` instance.
63+ */
1864 addDays ( amount : number ) : this;
65+
66+ /**
67+ * Add months to this date (mutates) and return `this`.
68+ * @param amount - Months to add (may be negative).
69+ * @returns The mutated `SonicDate` instance.
70+ */
1971 addMonths ( amount : number ) : this;
72+
73+ /**
74+ * Add years to this date (mutates) and return `this`.
75+ * @param amount - Years to add (may be negative).
76+ * @returns The mutated `SonicDate` instance.
77+ */
2078 addYears ( amount : number ) : this;
79+
80+ /**
81+ * Set time to the start of the day (00:00:00.000) and return `this`.
82+ * @returns The mutated `SonicDate` instance set to local start of day.
83+ */
2184 startOfDay ( ) : this;
85+
86+ /**
87+ * Get the minutes elapsed since local midnight (0-1439).
88+ * @returns Number of minutes from midnight.
89+ */
2290 minutesFromMidnight ( ) : number ;
91+
92+ /**
93+ * Get the number of full minutes between this date and `dateRight`.
94+ * @param dateRight - Date, timestamp or ISO string to compare against.
95+ * @returns Floor of minutes difference (this - dateRight).
96+ */
2397 differenceInMinutes ( dateRight : Dateable ) : number ;
98+
99+ /**
100+ * Get the number of full hours between this date and `dateRight`.
101+ * @param dateRight - Date, timestamp or ISO string to compare against.
102+ * @returns Floor of hours difference (this - dateRight).
103+ */
104+ differenceInHours ( dateRight : Dateable ) : number ;
105+
106+ /**
107+ * Get the number of full seconds between this date and `dateRight`.
108+ * @param dateRight - Date, timestamp or ISO string to compare against.
109+ * @returns Floor of seconds difference (this - dateRight).
110+ */
111+ differenceInSeconds ( dateRight : Dateable ) : number ;
112+
113+ /**
114+ * Get the difference in milliseconds between this date and `dateRight`.
115+ * @param dateRight - Date, timestamp or ISO string to compare against.
116+ * @returns Milliseconds difference (this - dateRight).
117+ */
118+ differenceInMs ( dateRight : Dateable ) : number ;
119+
120+ /**
121+ * Get the number of full calendar days between this date and `dateRight`.
122+ * @param dateRight - Date, timestamp or ISO string to compare against.
123+ * @returns Number of full days difference.
124+ */
24125 differenceInDays ( dateRight : Dateable ) : number ;
126+
127+ /**
128+ * Get the number of full years between this date and `dateRight`.
129+ * @param dateRight - Date, timestamp or ISO string to compare against.
130+ * @returns Number of full years difference.
131+ */
25132 differenceInYears ( dateRight : Dateable ) : number ;
133+
134+ /**
135+ * Return an ISO date string in `YYYY-MM-DD` format.
136+ * @returns ISO date string (date portion only).
137+ */
26138 toISODateString ( ) : string ;
139+
140+ /**
141+ * Return the epoch milliseconds adjusted to local UTC time.
142+ * This is equivalent to `getTime() - getTimezoneOffset() * 60000`.
143+ * @returns UTC-equivalent timestamp in milliseconds.
144+ */
27145 utcTime ( ) : number ;
28146}
29147
0 commit comments