Display activity date in local time (using the time zone that is stored with the activity), not in UTC #4
1 changed files with 12 additions and 1 deletions
|
|
@ -434,7 +434,7 @@ function formatDateTimeWithTimezone(timestamp, timezone, options = {}) {
|
||||||
|
|
||||||
// Parse the timestamp - backend sends LocalDateTime without 'Z'
|
// Parse the timestamp - backend sends LocalDateTime without 'Z'
|
||||||
// We need to interpret it in the specified timezone
|
// We need to interpret it in the specified timezone
|
||||||
const date = new Date(timestamp);
|
const date = new Date(ensureUTC(timestamp));
|
||||||
|
|
||||||
// Default options for date/time display
|
// Default options for date/time display
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
|
|
@ -473,6 +473,17 @@ function formatDateWithTimezone(timestamp, timezone) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures that a timestamp will be interpreted as UTC by new Date()
|
||||||
|
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date (Date time string format)
|
||||||
|
*
|
||||||
|
* @param {string} timestamp - ISO timestamp or LocalDateTime string
|
||||||
|
* @returns {string} The input string, but with a trailing 'Z'
|
||||||
|
*/
|
||||||
|
function ensureUTC(timestamp) {
|
||||||
|
return timestamp.endsWith('Z') ? timestamp : timestamp + 'Z';
|
||||||
|
}
|
||||||
|
|
||||||
// Make functions available globally for inline scripts
|
// Make functions available globally for inline scripts
|
||||||
window.FitPub = {
|
window.FitPub = {
|
||||||
createActivityMap,
|
createActivityMap,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue