[PR #8311] [CLOSED] Fix date parsing to respect user's configured date format in datagrid #8346

Closed
opened 2026-03-23 23:23:46 +00:00 by mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AppFlowy-IO/AppFlowy/pull/8311
Author: @Copilot
Created: 10/27/2025
Status: Closed

Base: mainHead: copilot/fix-date-format-issue


📝 Commits (4)

  • 92df44c Initial plan
  • 4aa2c72 Fix date parsing to respect user's configured date format
  • 7b40251 Improve date parsing to also handle date+time combined format
  • 7ae9062 Refactor to eliminate duplicate DateFormat creation

📊 Changes

2 files changed (+94 additions, -1 deletions)

View changed files

📝 frontend/appflowy_flutter/lib/workspace/presentation/widgets/date_picker/widgets/date_time_text_field.dart (+44 -1)
📝 frontend/appflowy_flutter/test/widget_test/date_picker_test.dart (+50 -0)

📄 Description

Date input parsing in datagrid fields ignored the user's configured date format (e.g., D/M/Y) and always used locale-based parsing (M/D/Y for en-US). Typing "2/9/2025" with D/M/Y format selected September 2nd in the UI but parsed as February 9th.

Changes

Modified parseDateTimeStr() in date_time_text_field.dart

  • Parse using configured date format pattern first (strict then lenient)
  • Handle date+time combined formats when includeTime is enabled
  • Fall back to AnyDate for natural language input ("tomorrow", etc.)

Added test coverage

  • Test case verifying DayMonthYear, US, and Local format parsing
  • Validates "2/9/2025" → Sept 2 for D/M/Y, Feb 9 for M/D/Y

Example

// Before: always used locale-based parsing
final parser = AnyDate.fromLocale(locale);
final result = parser.tryParse(string);

// After: respects configured format
try {
  return dateFormat.parseStrict(trimmedString); // e.g., dd/MM/y
} catch (_) {
  // Fall back to lenient parsing, date+time formats, then AnyDate
}

Maintains backward compatibility with natural language dates and all existing date format patterns (Local, US, ISO, Friendly, DayMonthYear).

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] Date format not respected in date type for datagrid</issue_title>
<issue_description>### Bug Description

My AppFlowy app is set to D/M/Y format. When I type in the date 2/9/2025 in a datagrid date field, it selects February 9th, 2025, not September 2nd, 2025. The format in the input seems to be forced M/D/Y. It only works correctly if the D portion is above 12.

How to Reproduce

Try putting a date into a date field that uses a day and month below 12.

Expected Behavior

Respect the Date format I've selected for the app.

Operating System

MacOS

AppFlowy Version(s)

10.0.2

Screenshots

No response

Additional Context

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

@LucasXu0 It can be reproduced in the latest version.

Image</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AppFlowy-IO/AppFlowy/pull/8311 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 10/27/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `copilot/fix-date-format-issue` --- ### 📝 Commits (4) - [`92df44c`](https://github.com/AppFlowy-IO/AppFlowy/commit/92df44cc8dd69cdc67c1eb428ed9f77927bf7f76) Initial plan - [`4aa2c72`](https://github.com/AppFlowy-IO/AppFlowy/commit/4aa2c7213e07c3dde548471baab1970e176be59a) Fix date parsing to respect user's configured date format - [`7b40251`](https://github.com/AppFlowy-IO/AppFlowy/commit/7b4025108eff781b8bdef9ba503ad774ac90b90e) Improve date parsing to also handle date+time combined format - [`7ae9062`](https://github.com/AppFlowy-IO/AppFlowy/commit/7ae906273a92b91ce988740b90ca196dd8332f8c) Refactor to eliminate duplicate DateFormat creation ### 📊 Changes **2 files changed** (+94 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `frontend/appflowy_flutter/lib/workspace/presentation/widgets/date_picker/widgets/date_time_text_field.dart` (+44 -1) 📝 `frontend/appflowy_flutter/test/widget_test/date_picker_test.dart` (+50 -0) </details> ### 📄 Description Date input parsing in datagrid fields ignored the user's configured date format (e.g., D/M/Y) and always used locale-based parsing (M/D/Y for en-US). Typing "2/9/2025" with D/M/Y format selected September 2nd in the UI but parsed as February 9th. ## Changes **Modified `parseDateTimeStr()` in `date_time_text_field.dart`** - Parse using configured date format pattern first (strict then lenient) - Handle date+time combined formats when `includeTime` is enabled - Fall back to `AnyDate` for natural language input ("tomorrow", etc.) **Added test coverage** - Test case verifying DayMonthYear, US, and Local format parsing - Validates "2/9/2025" → Sept 2 for D/M/Y, Feb 9 for M/D/Y ## Example ```dart // Before: always used locale-based parsing final parser = AnyDate.fromLocale(locale); final result = parser.tryParse(string); // After: respects configured format try { return dateFormat.parseStrict(trimmedString); // e.g., dd/MM/y } catch (_) { // Fall back to lenient parsing, date+time formats, then AnyDate } ``` Maintains backward compatibility with natural language dates and all existing date format patterns (Local, US, ISO, Friendly, DayMonthYear). <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[Bug] Date format not respected in date type for datagrid</issue_title> > <issue_description>### Bug Description > > My AppFlowy app is set to D/M/Y format. When I type in the date 2/9/2025 in a datagrid date field, it selects February 9th, 2025, not September 2nd, 2025. The format in the input seems to be forced M/D/Y. It only works correctly if the D portion is above 12. > > ### How to Reproduce > > Try putting a date into a date field that uses a day and month below 12. > > ### Expected Behavior > > Respect the Date format I've selected for the app. > > ### Operating System > > MacOS > > ### AppFlowy Version(s) > > 10.0.2 > > ### Screenshots > > _No response_ > > ### Additional Context > > _No response_</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > <comment_new><author>@LucasXu0</author><body> > It can be reproduced in the latest version. > > <img width="288" height="371" alt="Image" src="https://github.com/user-attachments/assets/94acb844-1d76-4fb0-b30e-3751664a2ed6" /></body></comment_new> > </comments> > </details> - Fixes AppFlowy-IO/AppFlowy#8310 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
mirror 2026-03-23 23:23:46 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#8346
No description provided.