Dynamic locale support for date formatting functions

Replaced hardcoded 'de-DE' locale with a new getCurrentCulture function that selects the user's culture from localized.culture or navigator.language. Date formatting now adapts to user language settings in detailedCurrentDate and getLocaleDateString.
This commit is contained in:
2026-02-16 17:34:49 +01:00
parent 7345b8f877
commit 8cf6484786
2 changed files with 5 additions and 3 deletions

View File

@@ -1,9 +1,11 @@
const getCurrentCulture = () => (typeof localized !== 'undefined' && localized.culture) ? localized.culture : (navigator.language || 'en-US');
const B64ToBuff = (base64String) => new Uint8Array(Array.from(atob(base64String), char => char.charCodeAt(0))).buffer;
const getLocaleDateString = _ => new Date().toLocaleDateString('de-DE')
const getLocaleDateString = _ => new Date().toLocaleDateString(getCurrentCulture())
function detailedCurrentDate() {
return new Intl.DateTimeFormat('de-DE', {
return new Intl.DateTimeFormat(getCurrentCulture(), {
day: '2-digit',
month: '2-digit',
year: 'numeric',

View File

@@ -1 +1 @@
function detailedCurrentDate(){return new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"shortOffset"}).format()}function findNearest(n,t,i,r){const u=r=>Math.sqrt((t(n)-t(r))**2+(i(n)-i(r))**2);return r.reduce((n,t)=>{const i=u(t);return i<n.dist?{dist:i,dest:t}:n},{dist:Infinity,dest:null}).dest}const B64ToBuff=n=>new Uint8Array(Array.from(atob(n),n=>n.charCodeAt(0))).buffer,getLocaleDateString=()=>(new Date).toLocaleDateString("de-DE");
function detailedCurrentDate(){return new Intl.DateTimeFormat(getCurrentCulture(),{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"shortOffset"}).format()}function findNearest(e,t,o,n){const r=n.reduce(((n,r)=>{const i=Math.sqrt((t(e)-t(r))**2+(o(e)-o(r))**2);return i<n.dist?{dist:i,dest:r}:n}),{dist:1/0,dest:null});return r.dest}const getCurrentCulture=()=>("undefined"!=typeof localized&&localized.culture)?localized.culture:navigator.language||"en-US";const B64ToBuff=e=>new Uint8Array(Array.from(atob(e),e=>e.charCodeAt(0))).buffer;const getLocaleDateString=e=>new Date().toLocaleDateString(getCurrentCulture());