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:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user