Fix date format inconsistency in Defer Until field (#941)
Fixes #938 The Defer Until field was using i18n.language directly instead of resolveUserLocale(), causing it to display dates in MM/DD/YYYY format (US default) regardless of timezone setting. Now uses the same locale resolution pattern as the Due Date field, which combines language with timezone-derived country code (e.g., "en" + Greek timezone → "en-GR" → DD/MM/YYYY format). Changes: - Import useMemo and resolveUserLocale - Add displayLocale memo to resolve timezone-aware locale - Use displayLocale instead of i18n.language in toLocaleString()
This commit is contained in:
parent
3486541272
commit
f1ea7843a7
1 changed files with 7 additions and 2 deletions
|
|
@ -1,8 +1,9 @@
|
|||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { ClockIcon } from '@heroicons/react/24/outline';
|
||||
import TaskDeferUntilSection from '../TaskForm/TaskDeferUntilSection';
|
||||
import { Task } from '../../../entities/Task';
|
||||
import { resolveUserLocale } from '../../../utils/localeUtils';
|
||||
|
||||
interface TaskDeferUntilCardProps {
|
||||
task: Task;
|
||||
|
|
@ -24,12 +25,16 @@ const TaskDeferUntilCard: React.FC<TaskDeferUntilCardProps> = ({
|
|||
onCancel,
|
||||
}) => {
|
||||
const { t, i18n } = useTranslation();
|
||||
const displayLocale = useMemo(
|
||||
() => resolveUserLocale(i18n.language),
|
||||
[i18n.language]
|
||||
);
|
||||
|
||||
const getDeferUntilDisplay = (deferUntil: string) => {
|
||||
const date = new Date(deferUntil);
|
||||
if (Number.isNaN(date.getTime())) return null;
|
||||
|
||||
const formattedDateTime = date.toLocaleString(i18n.language, {
|
||||
const formattedDateTime = date.toLocaleString(displayLocale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue