Skip to content

Commit 37a535c

Browse files
committed
refactor(calendar): consolidate date tokens into DATE_TOKENS Set
1 parent 8ab9dcb commit 37a535c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/versioning-strategies/calendar.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,21 +327,25 @@ class CalendarVersionUpdate implements VersionUpdater {
327327
}
328328
}
329329

330-
function isDateSegment(
331-
type: string
332-
): type is 'YYYY' | 'YY' | '0Y' | 'MM' | '0M' | 'WW' | '0W' | 'DD' | '0D' {
333-
return ['YYYY', 'YY', '0Y', 'MM', '0M', 'WW', '0W', 'DD', '0D'].includes(
334-
type
335-
);
336-
}
337-
338330
const SHORT_YEAR_EPOCH = 2000;
339331

340332
const YEAR_TOKENS = new Set(['YYYY', 'YY', '0Y']);
341333
const SHORT_YEAR_TOKENS = new Set(['YY', '0Y']);
342334
const MONTH_TOKENS = new Set(['MM', '0M']);
343335
const DAY_TOKENS = new Set(['DD', '0D']);
344336
const WEEK_TOKENS = new Set(['WW', '0W']);
337+
const DATE_TOKENS = new Set([
338+
...YEAR_TOKENS,
339+
...MONTH_TOKENS,
340+
...DAY_TOKENS,
341+
...WEEK_TOKENS,
342+
]);
343+
344+
function isDateSegment(
345+
type: string
346+
): type is 'YYYY' | 'YY' | '0Y' | 'MM' | '0M' | 'WW' | '0W' | 'DD' | '0D' {
347+
return DATE_TOKENS.has(type);
348+
}
345349

346350
function extractDateFromSegments(
347351
segments: CalVerSegment[],

0 commit comments

Comments
 (0)