1313/**
1414 * Peak hours, from api-docs.deepseek.com/quick_start/pricing (read 2026-08-16):
1515 * "Peak hours are 01:00 - 04:00 and 06:00 - 10:00 UTC (all other hours are
16- * off-peak)." These windows apply Monday-Friday Beijing time; weekends are
17- * always off-peak.
16+ * off-peak)." These windows apply Monday-Friday Beijing time; from
17+ * `DEEPSEEK_WEEKEND_OFFPEAK_EFFECTIVE_AT_UTC` onward, weekends are off-peak.
1818 *
1919 * Half-open [start, end): 04:00:00 UTC itself is already off-peak. TWO
2020 * disjoint windows, not one — the 04:00-06:00 gap between them is exactly what
@@ -29,7 +29,17 @@ export const DEEPSEEK_PEAK_HOUR_RANGES_UTC: ReadonlyArray<
2929
3030export type DeepSeekPricingWindow = 'peak' | 'off-peak'
3131
32- function isBeijingWeekend ( at : Date ) : boolean {
32+ /**
33+ * The weekend pricing change took effect at 00:00 Beijing time on 2026-08-23.
34+ * Keep this as an instant rather than a local date so historical billing and
35+ * availability checks use the same boundary in every runtime timezone.
36+ */
37+ export const DEEPSEEK_WEEKEND_OFFPEAK_EFFECTIVE_AT_UTC = Date . parse (
38+ '2026-08-22T16:00:00Z' ,
39+ )
40+
41+ /** Whether `at` falls on Saturday or Sunday in Beijing time. */
42+ export function isBeijingWeekend ( at : Date ) : boolean {
3343 const beijingDay = new Date ( at . getTime ( ) + 8 * 60 * 60 * 1000 ) . getUTCDay ( )
3444 return beijingDay === 0 || beijingDay === 6
3545}
@@ -42,7 +52,12 @@ function isBeijingWeekend(at: Date): boolean {
4252 * ceiling), and a hidden `new Date()` would make both untestable.
4353 */
4454export function deepseekPricingWindow ( at : Date ) : DeepSeekPricingWindow {
45- if ( isBeijingWeekend ( at ) ) return 'off-peak'
55+ if (
56+ at . getTime ( ) >= DEEPSEEK_WEEKEND_OFFPEAK_EFFECTIVE_AT_UTC &&
57+ isBeijingWeekend ( at )
58+ ) {
59+ return 'off-peak'
60+ }
4661 const hour = at . getUTCHours ( )
4762 const peak = DEEPSEEK_PEAK_HOUR_RANGES_UTC . some (
4863 ( [ startHour , endHour ] ) => hour >= startHour && hour < endHour ,
@@ -86,7 +101,12 @@ export const DEEPSEEK_EXPENSIVE_WINDOW_UTC: readonly [number, number] = [
86101/** Whether `at` falls in the window above. Half-open like the peak check, so
87102 * the closing hour is already outside it. */
88103export function isDeepSeekExpensiveWindow ( at : Date ) : boolean {
89- if ( isBeijingWeekend ( at ) ) return false
104+ if (
105+ at . getTime ( ) >= DEEPSEEK_WEEKEND_OFFPEAK_EFFECTIVE_AT_UTC &&
106+ isBeijingWeekend ( at )
107+ ) {
108+ return false
109+ }
90110 const [ start , end ] = DEEPSEEK_EXPENSIVE_WINDOW_UTC
91111 const hour = at . getUTCHours ( )
92112 return hour >= start && hour < end
0 commit comments