Changeset 421c2d4 in Klonkt for src/middleware


Ignore:
Timestamp:
06/21/2026 04:48:27 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
d6bdbae
Parents:
9effb80
Message:

feat(instellingen): site timezone — all dates + scheduling in chosen zone

Admin → Settings gets a Timezone picker (IANA, validated via Intl; empty =
server/UTC). Applied to: server-side date display (formatDate/formatDateTime
receive timeZone), and post scheduling (datetime-local is now interpreted/shown
in the site's zone instead of browser-local — wall↔UTC via Intl offset).
'Scheduled for' shows the time in the site's zone. NL/EN/DE.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/middleware/render.js

    r9effb80 r421c2d4  
    3131} catch { /* geen versie beschikbaar */ }
    3232
     33// Site-tijdzone (Beheer → Instellingen). Leeg = server-default (UTC). Wordt
     34// toegepast op álle server-side geformatteerde datums zodat ze in de zone van
     35// de site staan i.p.v. UTC.
     36const siteTimezone = () => getSetting('timezone') || undefined;
     37
    3338const formatDate = (iso) => {
    3439  if (!iso) return '';
    35   const d = new Date(iso);
    36   const months = ['januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december'];
    37   return `${d.getDate()} ${months[d.getMonth()]} ${d.getFullYear()}`;
     40  return new Date(iso).toLocaleDateString('nl-NL', { timeZone: siteTimezone(), day: 'numeric', month: 'long', year: 'numeric' });
    3841};
    3942
    4043const formatDateTime = (iso) => {
    4144  if (!iso) return '';
    42   const d = new Date(iso);
    43   return d.toLocaleString('nl-NL', { dateStyle: 'medium', timeStyle: 'short' });
     45  return new Date(iso).toLocaleString('nl-NL', { timeZone: siteTimezone(), dateStyle: 'medium', timeStyle: 'short' });
    4446};
    4547
     
    9193    t: (key, vars) => i18nT(_lang, key, vars),
    9294    langs: LANGS.map((c) => ({ code: c, name: LANG_NAMES[c], active: c === _lang })),
     95    timezone: getSetting('timezone') || '',
    9396    userOwnsSite,
    9497    canSeeBeheer,
Note: See TracChangeset for help on using the changeset viewer.