Display timestamps using the timezone that is stored at the activity (fix 'new Date()' invocation)
This commit is contained in:
parent
5f85417c80
commit
0625b5c0df
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'
|
||||
// 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
|
||||
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
|
||||
window.FitPub = {
|
||||
createActivityMap,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue