@@ -131,12 +131,12 @@ export const postToEndpoint = (url: string, post: boolean, jsonData: any) => {
131
131
} ;
132
132
133
133
export 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 ) ;
135
135
const diff = timestamp - now ;
136
136
137
- if ( diff <= 0 ) return "00:00:00" ; // Time has already passed
137
+ if ( diff <= 0 ) return "00:00:00" ;
138
138
139
- const days = Math . floor ( diff / 86400 ) ; // 86400 seconds in a day
139
+ const days = Math . floor ( diff / 86400 ) ;
140
140
const hours = Math . floor ( ( diff % 86400 ) / 3600 ) ;
141
141
const minutes = Math . floor ( ( diff % 3600 ) / 60 ) ;
142
142
const seconds = diff % 60 ;
@@ -154,14 +154,15 @@ export const getRemainingTime = (timestamp: number): string => {
154
154
) } :${ String ( seconds ) . padStart ( 2 , "0" ) } `;
155
155
} ;
156
156
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 ;
160
160
161
- if ( diff <= 0 ) return false ; // Time has already passed
161
+ const now = Math . floor ( Date . now ( ) ) ;
162
+ const expiresDate = new Date ( expires * 1000 ) ;
162
163
163
- return true ;
164
- } ;
164
+ return expiresDate . getTime ( ) > now
165
+ }
165
166
166
167
export const parseQueryParams = ( queryString : string ) => {
167
168
const params = new Map ( ) ;
0 commit comments