@@ -58,6 +58,22 @@ function dimensionParam(name: string, min: number, max: number) {
5858 . transform ( toDimensionValue ) ;
5959}
6060
61+ function isValidTimeZone ( tz ?: string ) : boolean {
62+ if ( ! tz ) return true ;
63+
64+ try {
65+ Intl . DateTimeFormat ( undefined , { timeZone : tz } ) ;
66+ return true ;
67+ } catch {
68+ return false ;
69+ }
70+ }
71+
72+ const timeZoneParam = z
73+ . string ( )
74+ . optional ( )
75+ . refine ( isValidTimeZone , { message : 'Invalid timezone' } ) ;
76+
6177const GITHUB_USERNAME_REGEX = / ^ [ a - z A - Z 0 - 9 ] (?: [ a - z A - Z 0 - 9 ] | - (? = [ a - z A - Z 0 - 9 ] ) ) * $ / ;
6278
6379export const streakParamsSchema = z . object ( {
@@ -174,6 +190,7 @@ export const streakParamsSchema = z.object({
174190 hide_background : z . string ( ) . optional ( ) . transform ( toBooleanFlag ) ,
175191 hide_stats : z . string ( ) . optional ( ) . transform ( toBooleanFlag ) ,
176192 lang : z . string ( ) . optional ( ) . default ( 'en' ) ,
193+ tz : timeZoneParam ,
177194 // Unknown view values fall back to the default dashboard view.
178195 view : z . enum ( [ 'default' , 'monthly' ] ) . catch ( 'default' ) . default ( 'default' ) ,
179196 // Invalid delta formats fall back to percentage mode.
@@ -282,7 +299,7 @@ export const statsParamsSchema = z.object({
282299 message : 'Invalid GitHub username' ,
283300 } ) ,
284301 refresh : z . string ( ) . optional ( ) . transform ( toRefreshFlag ) ,
285- tz : z . string ( ) . optional ( ) ,
302+ tz : timeZoneParam ,
286303} ) ;
287304
288305export const wrappedParamsSchema = z . object ( {
0 commit comments