@dvsa/appdev-api-common 0.5.1 → 0.6.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/package.json +1 -1
- package/utils/date-time.d.ts +6 -6
- package/utils/date-time.js +9 -10
package/package.json
CHANGED
package/utils/date-time.d.ts
CHANGED
|
@@ -63,6 +63,12 @@ export declare class DateTime {
|
|
|
63
63
|
* @returns Day of week
|
|
64
64
|
*/
|
|
65
65
|
day(): number;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the date to the start of a specified unit (mutable operation)
|
|
68
|
+
* @param unit - Unit of time (day, month, year, etc.)
|
|
69
|
+
* @returns This instance for chaining
|
|
70
|
+
*/
|
|
71
|
+
startOf(unit: dayjs.OpUnitType): DateTime;
|
|
66
72
|
/**
|
|
67
73
|
* Converts to string in UK date time format
|
|
68
74
|
* @returns Formatted date string
|
|
@@ -118,12 +124,6 @@ export declare class DateTime {
|
|
|
118
124
|
* @returns True if date is between start and end
|
|
119
125
|
*/
|
|
120
126
|
isBetween(startDate: AcceptableDate, endDate: AcceptableDate): boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Gets today's date in UK timezone
|
|
123
|
-
* For tests, returns a consistent date
|
|
124
|
-
* @returns Today as Date object
|
|
125
|
-
*/
|
|
126
|
-
static today(): Date;
|
|
127
127
|
/**
|
|
128
128
|
* Sets the timezone (mutable operation)
|
|
129
129
|
* @param tz - Timezone identifier
|
package/utils/date-time.js
CHANGED
|
@@ -120,6 +120,15 @@ class DateTime {
|
|
|
120
120
|
day() {
|
|
121
121
|
return this.instance.day();
|
|
122
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Sets the date to the start of a specified unit (mutable operation)
|
|
125
|
+
* @param unit - Unit of time (day, month, year, etc.)
|
|
126
|
+
* @returns This instance for chaining
|
|
127
|
+
*/
|
|
128
|
+
startOf(unit) {
|
|
129
|
+
this.instance = this.instance.startOf(unit);
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
123
132
|
/**
|
|
124
133
|
* Converts to string in UK date time format
|
|
125
134
|
* @returns Formatted date string
|
|
@@ -203,16 +212,6 @@ class DateTime {
|
|
|
203
212
|
return (this.instance.isAfter(start.instance) &&
|
|
204
213
|
this.instance.isBefore(end.instance));
|
|
205
214
|
}
|
|
206
|
-
/**
|
|
207
|
-
* Gets today's date in UK timezone
|
|
208
|
-
* For tests, returns a consistent date
|
|
209
|
-
* @returns Today as Date object
|
|
210
|
-
*/
|
|
211
|
-
static today() {
|
|
212
|
-
// This helps maintain consistent test expectations
|
|
213
|
-
// In tests, mock this method if needed
|
|
214
|
-
return (0, dayjs_1.default)("2023-05-15").toDate();
|
|
215
|
-
}
|
|
216
215
|
/**
|
|
217
216
|
* Sets the timezone (mutable operation)
|
|
218
217
|
* @param tz - Timezone identifier
|