Skip to content

fix(nag): parse ICU date formats when saving tasks#21

Merged
TDannhauer merged 1 commit into
FRAMEWORK_6_0from
fix/date_format
May 22, 2026
Merged

fix(nag): parse ICU date formats when saving tasks#21
TDannhauer merged 1 commit into
FRAMEWORK_6_0from
fix/date_format

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Parse ICU date formats when saving NAG tasks

Summary

Fixes saving tasks when date_format_mini uses ICU patterns (including the default short), which display correctly but were not parsed on submit.
The due-date form shows values via Format::formatDate() (e.g. 23.05.26 08:34 in de_DE), while Nag::parseDate() still called strptime() with the same preference. strptime() only accepts strftime specifiers, so parsing failed and fell back to new Horde_Date($date), which PHP DateTime also rejects for locale-specific strings.
For non-strftime formats, parseDate() now uses IcuFormatter with the user locale. Date and time are parsed separately when both are present, because ICU shortcuts like short cannot be combined with a custom time pattern in one IntlDateFormatter.
Legacy strftime date_format_mini values continue to use the existing strptime() path unchanged.

Test plan

Set Horde language to German and date_format_mini to abbreviated / short; create or edit a task with due date 23.05.26 and time 08:34; save — no Zeitformat … nicht erkannt error and due date persists correctly.

Repeat with 12-hour time (twentyFour off) and a due time like 8:34 AM.

Save a task with due date only (no time) and with “No due date” selected.

If an account still has a legacy strftime date_format_mini (e.g. %d.%m.%Y), confirm saving still works.

Edit recurrence end date (NagRecurrence, withtime = false) with a locale-formatted date string.

@TDannhauer TDannhauer requested a review from ralflang May 22, 2026 06:53
Comment thread lib/Nag.php
$timeFormat = $GLOBALS['prefs']->getValue('twentyFour') ? 'HH:mm' : 'h:mm a';
$timePart = $formatter->parse($parts[2], $timeFormat, $locale);

return new Horde_Date(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use Horde\Date\Date instead?

@TDannhauer TDannhauer merged commit efd4990 into FRAMEWORK_6_0 May 22, 2026
1 check failed
@ralflang ralflang added the bug label May 22, 2026
@ralflang ralflang changed the title Parse ICU date formats when saving NAG tasks fix(nag): parse ICU date formats when saving tasks May 22, 2026
@ralflang

Copy link
Copy Markdown
Member

This is still a stop-gap - If we know the formatted date and the format string, horde/date should be able to identify which formatter it is and create a Horde\Date\Date or Horde_Date compatible value from it.

ralflang added a commit that referenced this pull request May 28, 2026
Release version 5.0.0-RC3

Refactor tasklist cache and sync list handling
Refactor task retrieval logic in Sql.php
fix(security): restrict unserialize allowed_classes (ZDI-20-1051)
refactor: Transition to unified screen.css
Remove persistPrefs() calls from tasklist methods
Refactor ActiveSync task list cache handling
Update Nag.php
Refactor tasklist creation to include sync options
Enhance addTasklist with synchronization and persistence
Enhance tasklist management with sync functionality
Refactor ActiveSync error handling and notifications
Sync tasklist after adding it
Refactor synchronization of tasklist addition
Refactor sync_lists handling in task management
chore: Update workflow dependency
Merge pull request #23 from horde/refactor/adopt-format-parse
refactor(nag): delegate parseDate() to Format::parse()
Update addTasklist method documentation
Merge pull request #22 from horde/fix/array_offset_access
Merge pull request #21 from horde/fix/date_format
Enhance validation checks in NagMethod
Refactor getInfo and isValid methods for NagAlarm
Add ICU date formatting support in parseDate method
Merge pull request #20 from horde/refactor/multi_tasklist_usage_2
refactor: Use controllers rather than globals. Addresses #19
refactor: Replace strftime with IntlDateFormatter
refactor(injector): Widen type hints from Horde_Injector to Horde_Injector|Injector
style: constrain tag list icon size to 16px
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants