Commit eeb0687 1 parent 2d237b9 commit eeb0687 Copy full SHA for eeb0687
File tree 2 files changed +17
-11
lines changed
routes/taxi/availability/api/tour
2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change 1
- import type { UnixtimeMs } from " ./UnixtimeMs" ;
1
+ import type { UnixtimeMs } from ' ./UnixtimeMs' ;
2
2
3
3
export const SECOND = 1000 ;
4
4
export const MINUTE = SECOND * 60 ;
@@ -14,9 +14,13 @@ export function secondToMilli(second: number): number {
14
14
}
15
15
16
16
export function getOffset ( t : UnixtimeMs ) {
17
- return parseInt ( new Date ( Math . floor ( t / DAY ) * DAY + 12 * HOUR ) . toLocaleString ( 'de-DE' , {
18
- hour : '2-digit' ,
19
- hour12 : false ,
20
- timeZone : 'Europe/Berlin'
21
- } ) ) - 12 ;
22
- } ;
17
+ return (
18
+ parseInt (
19
+ new Date ( Math . floor ( t / DAY ) * DAY + 12 * HOUR ) . toLocaleString ( 'de-DE' , {
20
+ hour : '2-digit' ,
21
+ hour12 : false ,
22
+ timeZone : 'Europe/Berlin'
23
+ } )
24
+ ) - 12
25
+ ) ;
26
+ }
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { json } from '@sveltejs/kit';
2
2
import { db } from '$lib/server/db' ;
3
3
import { sql } from 'kysely' ;
4
4
import { jsonArrayFrom } from 'kysely/helpers/postgres' ;
5
- import { DAY , getOffset , HOUR } from '$lib/util/time' ;
5
+ import { getOffset , HOUR } from '$lib/util/time' ;
6
6
7
7
export const POST = async ( event ) => {
8
8
function getLatestEventTime ( ev : {
@@ -69,9 +69,11 @@ export const POST = async (event) => {
69
69
! movedTour . requests . some ( ( r ) => r . events . length == 0 ) ,
70
70
'Found a request which contains no events.'
71
71
) ;
72
-
73
- const firstEventTime = Math . min ( ...( movedTour . requests . flatMap ( ( r ) => r . events . map ( ( e ) => getLatestEventTime ( e ) ) ) ) ) ;
74
- if ( firstEventTime < Date . now ( ) + getOffset ( Date . now ( ) ) * HOUR ) {
72
+
73
+ const firstEventTime = Math . min (
74
+ ...movedTour . requests . flatMap ( ( r ) => r . events . map ( ( e ) => getLatestEventTime ( e ) ) )
75
+ ) ;
76
+ if ( firstEventTime < Date . now ( ) + getOffset ( Date . now ( ) ) * HOUR ) {
75
77
return ;
76
78
}
77
79
const collidingTours = await trx
You can’t perform that action at this time.
0 commit comments