|
1 | 1 | import type { ReportFormat, ReportFormatMetadata } from './reportAdapters' |
| 2 | +import { isValidIsoDate } from './isoDate' |
2 | 3 |
|
3 | 4 | export type QuotaUnit = 'pru' | 'aic' |
4 | 5 | export type OrganizationIncludedCreditTier = 'business' | 'enterprise' |
@@ -37,7 +38,6 @@ export type ReportPeriod = { |
37 | 38 | const COPILOT_BUSINESS_LABEL = 'Copilot Business' |
38 | 39 | const COPILOT_ENTERPRISE_LABEL = 'Copilot Enterprise' |
39 | 40 | const NATIVE_AI_CREDITS_STANDARD_POLICY_START_DATE = '2026-09-01' |
40 | | -const ISO_DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/ |
41 | 41 |
|
42 | 42 | export const TRANSITION_PERIOD_INCLUDED_CREDITS_POLICY = { |
43 | 43 | id: 'transition-period-billing-preview', |
@@ -117,22 +117,6 @@ function getReportFormat(reportMetadataOrFormat: ReportFormat | ReportFormatMeta |
117 | 117 | : reportMetadataOrFormat.format |
118 | 118 | } |
119 | 119 |
|
120 | | -function isValidIsoDate(value: string): boolean { |
121 | | - const match = ISO_DATE_PATTERN.exec(value) |
122 | | - if (!match) return false |
123 | | - |
124 | | - const year = Number(match[1]) |
125 | | - const month = Number(match[2]) |
126 | | - const day = Number(match[3]) |
127 | | - const date = new Date(Date.UTC(year, month - 1, day)) |
128 | | - |
129 | | - return ( |
130 | | - date.getUTCFullYear() === year |
131 | | - && date.getUTCMonth() === month - 1 |
132 | | - && date.getUTCDate() === day |
133 | | - ) |
134 | | -} |
135 | | - |
136 | 120 | function isBeforeIsoDate(value: string | null | undefined, boundary: string): boolean { |
137 | 121 | if (!value || !isValidIsoDate(value)) return false |
138 | 122 |
|
|
0 commit comments