File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ export async function GET(request: Request) {
3939 radius,
4040 font,
4141 year,
42+ from : customFrom ,
43+ to : customTo ,
4244 refresh,
4345 hide_title,
4446 hide_background,
@@ -57,8 +59,16 @@ export async function GET(request: Request) {
5759 } = parseResult . data ;
5860
5961 const themeName = theme || 'dark' ;
60- const from = year ? `${ year } -01-01T00:00:00Z` : undefined ;
61- const to = year ? `${ year } -12-31T23:59:59Z` : undefined ;
62+ const from = customFrom
63+ ? new Date ( customFrom ) . toISOString ( )
64+ : year
65+ ? `${ year } -01-01T00:00:00Z`
66+ : undefined ;
67+ const to = customTo
68+ ? new Date ( customTo ) . toISOString ( )
69+ : year
70+ ? `${ year } -12-31T23:59:59Z`
71+ : undefined ;
6272
6373 const tzParam = searchParams . get ( 'tz' ) ;
6474 let timezone = 'UTC' ;
Original file line number Diff line number Diff line change @@ -95,6 +95,26 @@ export const streakParamsSchema = z.object({
9595 message : 'GitHub was founded in 2008. Please provide a year of 2008 or later.' ,
9696 }
9797 ) ,
98+ from : z
99+ . string ( )
100+ . optional ( )
101+ . refine (
102+ ( val ) => {
103+ if ( ! val ) return true ;
104+ return ! isNaN ( Date . parse ( val ) ) ;
105+ } ,
106+ { message : 'Invalid "from" date format. Use ISO 8601 (e.g. 2023-01-01).' }
107+ ) ,
108+ to : z
109+ . string ( )
110+ . optional ( )
111+ . refine (
112+ ( val ) => {
113+ if ( ! val ) return true ;
114+ return ! isNaN ( Date . parse ( val ) ) ;
115+ } ,
116+ { message : 'Invalid "to" date format. Use ISO 8601 (e.g. 2023-12-31).' }
117+ ) ,
98118 refresh : z
99119 . string ( )
100120 . optional ( )
You can’t perform that action at this time.
0 commit comments