@@ -131,12 +131,12 @@ export const postToEndpoint = (url: string, post: boolean, jsonData: any) => {
131131} ;
132132
133133export const getRemainingTime = ( timestamp : number ) : string => {
134- const now = Math . floor ( Date . now ( ) / 1000 ) ; // Convert current time to seconds
134+ const now = Math . floor ( Date . now ( ) / 1000 ) ;
135135 const diff = timestamp - now ;
136136
137- if ( diff <= 0 ) return "00:00:00" ; // Time has already passed
137+ if ( diff <= 0 ) return "00:00:00" ;
138138
139- const days = Math . floor ( diff / 86400 ) ; // 86400 seconds in a day
139+ const days = Math . floor ( diff / 86400 ) ;
140140 const hours = Math . floor ( ( diff % 86400 ) / 3600 ) ;
141141 const minutes = Math . floor ( ( diff % 3600 ) / 60 ) ;
142142 const seconds = diff % 60 ;
@@ -154,14 +154,15 @@ export const getRemainingTime = (timestamp: number): string => {
154154 ) } :${ String ( seconds ) . padStart ( 2 , "0" ) } `;
155155} ;
156156
157- export const isPassportValid = ( timestamp : number ) : boolean => {
158- const now = Math . floor ( Date . now ( ) / 1000 ) ; // Convert current time to seconds
159- const diff = timestamp - now ;
157+ export const isPassportValid = ( expires : number | undefined ) => {
158+ if ( ! expires ) return false ;
159+ if ( expires > 32503690800000 ) return true ;
160160
161- if ( diff <= 0 ) return false ; // Time has already passed
161+ const now = Math . floor ( Date . now ( ) ) ;
162+ const expiresDate = new Date ( expires * 1000 ) ;
162163
163- return true ;
164- } ;
164+ return expiresDate . getTime ( ) > now
165+ }
165166
166167export const parseQueryParams = ( queryString : string ) => {
167168 const params = new Map ( ) ;
0 commit comments