From de7d5e7c7e0e33a7815661007f52c5df10e3b8c6 Mon Sep 17 00:00:00 2001 From: Kerry Date: Thu, 28 Apr 2022 18:03:58 +0200 Subject: [PATCH] handle safari cocoa core data timestamps (#8440) --- src/utils/beacon/geolocation.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/beacon/geolocation.ts b/src/utils/beacon/geolocation.ts index 330651b520..e8923afbf2 100644 --- a/src/utils/beacon/geolocation.ts +++ b/src/utils/beacon/geolocation.ts @@ -86,8 +86,13 @@ export const genericPositionFromGeolocation = (geoPosition: GeolocationPosition) const { latitude, longitude, altitude, accuracy, } = geoPosition.coords; + return { - timestamp: geoPosition.timestamp, + // safari reports geolocation timestamps as Apple Cocoa Core Data timestamp + // or ms since 1/1/2001 instead of the regular epoch + // they also use local time, not utc + // to simplify, just use Date.now() + timestamp: Date.now(), latitude, longitude, altitude, accuracy, }; };