Skip to content

Commit a521592

Browse files
Copilotmrjf
andauthored
fix: resolve remaining CI lint/test failures across repo
Agent-Logs-Url: https://github.com/githubnext/tsessebe/sessions/ae9911fe-dbd2-4c2d-b246-82e7a320d4ac Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
1 parent 25ae11a commit a521592

73 files changed

Lines changed: 1648 additions & 1129 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/core/date_offset.ts

Lines changed: 75 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ function isBusinessDay(date: Date): boolean {
140140
* - If on a month-end: advance `n` months directly.
141141
*/
142142
function applyMonthEnd(date: Date, n: number): Date {
143-
if (n === 0) return new Date(date.getTime());
143+
if (n === 0) {
144+
return new Date(date.getTime());
145+
}
144146
const y = date.getUTCFullYear();
145147
const m = date.getUTCMonth();
146148
if (isMonthEnd(date)) {
@@ -158,7 +160,9 @@ function applyMonthEnd(date: Date, n: number): Date {
158160
* Mirrors `pandas.tseries.offsets.MonthBegin(n).apply(date)`.
159161
*/
160162
function applyMonthBegin(date: Date, n: number): Date {
161-
if (n === 0) return new Date(date.getTime());
163+
if (n === 0) {
164+
return new Date(date.getTime());
165+
}
162166
const y = date.getUTCFullYear();
163167
const m = date.getUTCMonth();
164168
if (isMonthBegin(date) || n > 0) {
@@ -172,10 +176,16 @@ function applyMonthBegin(date: Date, n: number): Date {
172176
* Mirrors `pandas.tseries.offsets.YearEnd(n).apply(date)`.
173177
*/
174178
function applyYearEnd(date: Date, n: number): Date {
175-
if (n === 0) return new Date(date.getTime());
179+
if (n === 0) {
180+
return new Date(date.getTime());
181+
}
176182
const y = date.getUTCFullYear();
177-
if (isYearEnd(date)) return new Date(Date.UTC(y + n, 11, 31));
178-
if (n > 0) return new Date(Date.UTC(y + n - 1, 11, 31));
183+
if (isYearEnd(date)) {
184+
return new Date(Date.UTC(y + n, 11, 31));
185+
}
186+
if (n > 0) {
187+
return new Date(Date.UTC(y + n - 1, 11, 31));
188+
}
179189
return new Date(Date.UTC(y + n, 11, 31));
180190
}
181191

@@ -184,9 +194,13 @@ function applyYearEnd(date: Date, n: number): Date {
184194
* Mirrors `pandas.tseries.offsets.YearBegin(n).apply(date)`.
185195
*/
186196
function applyYearBegin(date: Date, n: number): Date {
187-
if (n === 0) return new Date(date.getTime());
197+
if (n === 0) {
198+
return new Date(date.getTime());
199+
}
188200
const y = date.getUTCFullYear();
189-
if (isYearBegin(date) || n > 0) return new Date(Date.UTC(y + n, 0, 1));
201+
if (isYearBegin(date) || n > 0) {
202+
return new Date(Date.UTC(y + n, 0, 1));
203+
}
190204
return new Date(Date.UTC(y + n + 1, 0, 1));
191205
}
192206

@@ -229,8 +243,10 @@ function applyBday(date: Date, n: number): Date {
229243
* Returns `date` unchanged if it already falls on `jsDow`.
230244
*/
231245
function rollFwdWeekday(date: Date, jsDow: number): Date {
232-
const daysAhead = ((jsDow - date.getUTCDay()) + 7) % 7;
233-
if (daysAhead === 0) return new Date(date.getTime());
246+
const daysAhead = (jsDow - date.getUTCDay() + 7) % 7;
247+
if (daysAhead === 0) {
248+
return new Date(date.getTime());
249+
}
234250
return new Date(date.getTime() + daysAhead * MS_PER_DAY);
235251
}
236252

@@ -239,8 +255,10 @@ function rollFwdWeekday(date: Date, jsDow: number): Date {
239255
* Returns `date` unchanged if it already falls on `jsDow`.
240256
*/
241257
function rollBkWeekday(date: Date, jsDow: number): Date {
242-
const daysBack = ((date.getUTCDay() - jsDow) + 7) % 7;
243-
if (daysBack === 0) return new Date(date.getTime());
258+
const daysBack = (date.getUTCDay() - jsDow + 7) % 7;
259+
if (daysBack === 0) {
260+
return new Date(date.getTime());
261+
}
244262
return new Date(date.getTime() - daysBack * MS_PER_DAY);
245263
}
246264

@@ -249,17 +267,23 @@ function rollBkWeekday(date: Date, jsDow: number): Date {
249267
* `jsDow` is null for plain (unaligned) weeks.
250268
*/
251269
function applyWeek(date: Date, n: number, jsDow: number | null): Date {
252-
if (n === 0) return new Date(date.getTime());
270+
if (n === 0) {
271+
return new Date(date.getTime());
272+
}
253273
if (jsDow === null) {
254274
return new Date(date.getTime() + n * MS_PER_WEEK);
255275
}
256276
const onTarget = date.getUTCDay() === jsDow;
257277
if (n > 0) {
258-
if (onTarget) return new Date(date.getTime() + n * MS_PER_WEEK);
278+
if (onTarget) {
279+
return new Date(date.getTime() + n * MS_PER_WEEK);
280+
}
259281
const rolled = rollFwdWeekday(date, jsDow);
260282
return new Date(rolled.getTime() + (n - 1) * MS_PER_WEEK);
261283
}
262-
if (onTarget) return new Date(date.getTime() + n * MS_PER_WEEK);
284+
if (onTarget) {
285+
return new Date(date.getTime() + n * MS_PER_WEEK);
286+
}
263287
const rolled = rollBkWeekday(date, jsDow);
264288
return new Date(rolled.getTime() + (n + 1) * MS_PER_WEEK);
265289
}
@@ -500,7 +524,10 @@ export class Week implements DateOffset {
500524
*/
501525
readonly weekday: number | null;
502526

503-
constructor(readonly n = 1, options: WeekOptions = {}) {
527+
constructor(
528+
readonly n = 1,
529+
options: WeekOptions = {},
530+
) {
504531
this.weekday = options.weekday ?? null;
505532
}
506533

@@ -514,17 +541,23 @@ export class Week implements DateOffset {
514541
}
515542

516543
rollforward(date: Date): Date {
517-
if (this.weekday === null) return new Date(date.getTime());
544+
if (this.weekday === null) {
545+
return new Date(date.getTime());
546+
}
518547
return rollFwdWeekday(date, pdToJsDow(this.weekday));
519548
}
520549

521550
rollback(date: Date): Date {
522-
if (this.weekday === null) return new Date(date.getTime());
551+
if (this.weekday === null) {
552+
return new Date(date.getTime());
553+
}
523554
return rollBkWeekday(date, pdToJsDow(this.weekday));
524555
}
525556

526557
onOffset(date: Date): boolean {
527-
if (this.weekday === null) return true;
558+
if (this.weekday === null) {
559+
return true;
560+
}
528561
return date.getUTCDay() === pdToJsDow(this.weekday);
529562
}
530563

@@ -569,14 +602,18 @@ export class MonthEnd implements DateOffset {
569602
}
570603

571604
rollforward(date: Date): Date {
572-
if (isMonthEnd(date)) return new Date(date.getTime());
605+
if (isMonthEnd(date)) {
606+
return new Date(date.getTime());
607+
}
573608
const y = date.getUTCFullYear();
574609
const m = date.getUTCMonth();
575610
return new Date(Date.UTC(y, m + 1, 0));
576611
}
577612

578613
rollback(date: Date): Date {
579-
if (isMonthEnd(date)) return new Date(date.getTime());
614+
if (isMonthEnd(date)) {
615+
return new Date(date.getTime());
616+
}
580617
const y = date.getUTCFullYear();
581618
const m = date.getUTCMonth();
582619
return new Date(Date.UTC(y, m, 0));
@@ -626,14 +663,18 @@ export class MonthBegin implements DateOffset {
626663
}
627664

628665
rollforward(date: Date): Date {
629-
if (isMonthBegin(date)) return new Date(date.getTime());
666+
if (isMonthBegin(date)) {
667+
return new Date(date.getTime());
668+
}
630669
const y = date.getUTCFullYear();
631670
const m = date.getUTCMonth();
632671
return new Date(Date.UTC(y, m + 1, 1));
633672
}
634673

635674
rollback(date: Date): Date {
636-
if (isMonthBegin(date)) return new Date(date.getTime());
675+
if (isMonthBegin(date)) {
676+
return new Date(date.getTime());
677+
}
637678
const y = date.getUTCFullYear();
638679
const m = date.getUTCMonth();
639680
return new Date(Date.UTC(y, m, 1));
@@ -679,12 +720,16 @@ export class YearEnd implements DateOffset {
679720
}
680721

681722
rollforward(date: Date): Date {
682-
if (isYearEnd(date)) return new Date(date.getTime());
723+
if (isYearEnd(date)) {
724+
return new Date(date.getTime());
725+
}
683726
return new Date(Date.UTC(date.getUTCFullYear(), 11, 31));
684727
}
685728

686729
rollback(date: Date): Date {
687-
if (isYearEnd(date)) return new Date(date.getTime());
730+
if (isYearEnd(date)) {
731+
return new Date(date.getTime());
732+
}
688733
return new Date(Date.UTC(date.getUTCFullYear() - 1, 11, 31));
689734
}
690735

@@ -727,12 +772,16 @@ export class YearBegin implements DateOffset {
727772
}
728773

729774
rollforward(date: Date): Date {
730-
if (isYearBegin(date)) return new Date(date.getTime());
775+
if (isYearBegin(date)) {
776+
return new Date(date.getTime());
777+
}
731778
return new Date(Date.UTC(date.getUTCFullYear() + 1, 0, 1));
732779
}
733780

734781
rollback(date: Date): Date {
735-
if (isYearBegin(date)) return new Date(date.getTime());
782+
if (isYearBegin(date)) {
783+
return new Date(date.getTime());
784+
}
736785
return new Date(Date.UTC(date.getUTCFullYear(), 0, 1));
737786
}
738787

0 commit comments

Comments
 (0)