[PR #8213] Fix date query handler to use 1-based month/day and add regression test #8310

Open
opened 2026-03-23 23:23:35 +00:00 by mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AppFlowy-IO/AppFlowy/pull/8213
Author: @KAVYANSHTYAGI
Created: 9/10/2025
Status: 🔄 Open

Base: mainHead: date-fix


📝 Commits (1)

  • e6b982c fix date handler off-by-one

📊 Changes

1 file changed (+13 additions, -1 deletions)

View changed files

📝 frontend/rust-lib/flowy-date/src/event_handler.rs (+13 -1)

📄 Description

Description

This PR addresses a bug in the date query handler where NaiveDate::from_ymd_opt was constructed with month0()/day0(), leading to invalid or missing dates when substituting a parsed year.

Changes

  • Replaced month0()/day0() with 1-based month() and day() to correctly construct dates.
  • Added an async regression test (parses_year_from_query) to ensure queries like "June 5 2024" correctly format to "2024-06-05".

Notes

  • Preserves fallback behavior: if the constructed date is invalid (e.g., leap year rollover), the handler falls back to the original parsed date string.
  • No API changes; only internal correctness and test coverage improvements.

Summary by Sourcery

Fix the date query handler to use 1-based month and day in NaiveDate construction and add a regression test to verify correct year parsing.

Bug Fixes:

  • Use 1-based month() and day() instead of month0()/day0() when constructing dates to prevent invalid or missing dates

Tests:

  • Add an async regression test to ensure queries like "June 5 2024" format correctly to "2024-06-05"

🔄 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/8213 **Author:** [@KAVYANSHTYAGI](https://github.com/KAVYANSHTYAGI) **Created:** 9/10/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `date-fix` --- ### 📝 Commits (1) - [`e6b982c`](https://github.com/AppFlowy-IO/AppFlowy/commit/e6b982c68a4375787738ce47660e01ac096e22eb) fix date handler off-by-one ### 📊 Changes **1 file changed** (+13 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `frontend/rust-lib/flowy-date/src/event_handler.rs` (+13 -1) </details> ### 📄 Description Description This PR addresses a bug in the date query handler where NaiveDate::from_ymd_opt was constructed with month0()/day0(), leading to invalid or missing dates when substituting a parsed year. Changes - Replaced month0()/day0() with 1-based month() and day() to correctly construct dates. - Added an async regression test (parses_year_from_query) to ensure queries like "June 5 2024" correctly format to "2024-06-05". Notes - Preserves fallback behavior: if the constructed date is invalid (e.g., leap year rollover), the handler falls back to the original parsed date string. - No API changes; only internal correctness and test coverage improvements. ## Summary by Sourcery Fix the date query handler to use 1-based month and day in NaiveDate construction and add a regression test to verify correct year parsing. Bug Fixes: - Use 1-based month() and day() instead of month0()/day0() when constructing dates to prevent invalid or missing dates Tests: - Add an async regression test to ensure queries like "June 5 2024" format correctly to "2024-06-05" --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#8310
No description provided.