fix: preserve dmy=DD.MM.YYYY, add dmy_slash for DD/MM/YYYY
The PR changed dmy from dots to slashes, breaking existing users. Revert dmy to dots (backward compat), add dmy_slash for DD/MM/YYYY. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-3
@@ -87,7 +87,7 @@ function isDateOnlyString(value) {
|
||||
return typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value);
|
||||
}
|
||||
|
||||
const VALID_DATE_FORMATS = ['mdy', 'dmy', 'ymd', 'mdy_dot', 'dmy_dot', 'ymd_dot', 'ymd_slash'];
|
||||
const VALID_DATE_FORMATS = ['mdy', 'dmy', 'ymd', 'mdy_dot', 'dmy_dot', 'dmy_slash', 'ymd_dot', 'ymd_slash'];
|
||||
|
||||
function getDateFormatPreference() {
|
||||
const stored = localStorage.getItem(DATE_FORMAT_KEY);
|
||||
@@ -114,9 +114,10 @@ function formatDateParts(date, useUtc = false) {
|
||||
const month = String((useUtc ? d.getUTCMonth() : d.getMonth()) + 1).padStart(2, '0');
|
||||
const day = String(useUtc ? d.getUTCDate() : d.getDate()).padStart(2, '0');
|
||||
switch (getDateFormatPreference()) {
|
||||
case 'dmy': return `${day}/${month}/${year}`;
|
||||
case 'dmy': return `${day}.${month}.${year}`;
|
||||
case 'mdy_dot': return `${month}.${day}.${year}`;
|
||||
case 'dmy_dot': return `${day}.${month}.${year}`;
|
||||
case 'dmy_slash': return `${day}/${month}/${year}`;
|
||||
case 'ymd': return `${year}-${month}-${day}`;
|
||||
case 'ymd_dot': return `${year}.${month}.${day}`;
|
||||
case 'ymd_slash': return `${year}/${month}/${day}`;
|
||||
@@ -145,9 +146,10 @@ export function formatDate(date) {
|
||||
|
||||
export function dateInputPlaceholder() {
|
||||
switch (getDateFormatPreference()) {
|
||||
case 'dmy': return 'DD/MM/YYYY';
|
||||
case 'dmy': return 'DD.MM.YYYY';
|
||||
case 'mdy_dot': return 'MM.DD.YYYY';
|
||||
case 'dmy_dot': return 'DD.MM.YYYY';
|
||||
case 'dmy_slash': return 'DD/MM/YYYY';
|
||||
case 'ymd': return 'YYYY-MM-DD';
|
||||
case 'ymd_dot': return 'YYYY.MM.DD';
|
||||
case 'ymd_slash': return 'YYYY/MM/DD';
|
||||
|
||||
@@ -338,10 +338,10 @@ export async function render(container, { user }) {
|
||||
<label class="form-label" for="date-format-select">${t('settings.dateFormatLabel')}</label>
|
||||
<select class="form-input" id="date-format-select">
|
||||
<option value="mdy"${prefs.date_format === 'mdy' ? ' selected' : ''}>MM/DD/YYYY</option>
|
||||
<option value="dmy"${prefs.date_format === 'dmy' ? ' selected' : ''}>DD/MM/YYYY</option>
|
||||
<option value="dmy"${prefs.date_format === 'dmy' ? ' selected' : ''}>DD.MM.YYYY</option>
|
||||
<option value="dmy_slash"${prefs.date_format === 'dmy_slash' ? ' selected' : ''}>DD/MM/YYYY</option>
|
||||
<option value="ymd"${prefs.date_format === 'ymd' ? ' selected' : ''}>YYYY-MM-DD</option>
|
||||
<option value="mdy_dot"${prefs.date_format === 'mdy_dot' ? ' selected' : ''}>MM.DD.YYYY</option>
|
||||
<option value="dmy_dot"${prefs.date_format === 'dmy_dot' ? ' selected' : ''}>DD.MM.YYYY</option>
|
||||
<option value="ymd_dot"${prefs.date_format === 'ymd_dot' ? ' selected' : ''}>YYYY.MM.DD</option>
|
||||
<option value="ymd_slash"${prefs.date_format === 'ymd_slash' ? ' selected' : ''}>YYYY/MM/DD</option>
|
||||
</select>
|
||||
|
||||
@@ -20,7 +20,7 @@ const VALID_CURRENCIES = ['AED', 'AUD', 'BRL', 'CAD', 'CHF', 'CNY', 'CZK', 'DKK'
|
||||
const DEFAULT_CURRENCY = 'EUR';
|
||||
const DEFAULT_APP_NAME = 'Oikos';
|
||||
|
||||
const VALID_DATE_FORMATS = ['mdy', 'dmy', 'ymd', 'mdy_dot', 'dmy_dot', 'ymd_dot', 'ymd_slash'];
|
||||
const VALID_DATE_FORMATS = ['mdy', 'dmy', 'ymd', 'mdy_dot', 'dmy_dot', 'dmy_slash', 'ymd_dot', 'ymd_slash'];
|
||||
const DEFAULT_DATE_FORMAT = 'mdy';
|
||||
const VALID_TIME_FORMATS = ['24h', '12h'];
|
||||
const DEFAULT_TIME_FORMAT = '24h';
|
||||
|
||||
Reference in New Issue
Block a user