mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-14 03:01:39 -05:00
Update map popup to format dates with the locale from the browser
This commit is contained in:
parent
e7a38fa55d
commit
bf8dc7f872
2 changed files with 5 additions and 3 deletions
|
|
@ -55,7 +55,8 @@ export function minutesToDaysHoursMinutes(minutes) {
|
|||
|
||||
export function formatDate(timestamp, timezone) {
|
||||
const date = new Date(timestamp * 1000);
|
||||
return date.toLocaleString("en-GB", { timeZone: timezone });
|
||||
const locale = navigator.languages !== undefined ? navigator.languages[0] : navigator.language;
|
||||
return date.toLocaleString(locale, { timeZone: timezone });
|
||||
}
|
||||
|
||||
export function haversineDistance(lat1, lon1, lat2, lon2, unit = 'km') {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { formatDate } from "../maps/helpers";
|
||||
import { formatDistance } from "../maps/helpers";
|
||||
import { getUrlParameter } from "../maps/helpers";
|
||||
import { minutesToDaysHoursMinutes } from "../maps/helpers";
|
||||
|
|
@ -12,8 +13,8 @@ export function addHighlightOnHover(polyline, map, polylineCoordinates, userSett
|
|||
const startPoint = polylineCoordinates[0];
|
||||
const endPoint = polylineCoordinates[polylineCoordinates.length - 1];
|
||||
|
||||
const firstTimestamp = new Date(startPoint[4] * 1000).toLocaleString("en-GB", { timeZone: userSettings.timezone });
|
||||
const lastTimestamp = new Date(endPoint[4] * 1000).toLocaleString("en-GB", { timeZone: userSettings.timezone });
|
||||
const firstTimestamp = formatDate(startPoint[4], userSettings.timezone);
|
||||
const lastTimestamp = formatDate(endPoint[4], userSettings.timezone);
|
||||
|
||||
const minutes = Math.round((endPoint[4] - startPoint[4]) / 60);
|
||||
const timeOnRoute = minutesToDaysHoursMinutes(minutes);
|
||||
|
|
|
|||
Loading…
Reference in a new issue