Skip to content

fix: allow dates before unix epoch - #9000

Open
kaluli123123 wants to merge 3 commits into
AppFlowy-IO:mainfrom
kaluli123123:fix/8681-date-before-1970
Open

fix: allow dates before unix epoch#9000
kaluli123123 wants to merge 3 commits into
AppFlowy-IO:mainfrom
kaluli123123:fix/8681-date-before-1970

Conversation

@kaluli123123

@kaluli123123 kaluli123123 commented Sep 8, 2026

Copy link
Copy Markdown

Summary

  • allow the date picker to select dates before the Unix epoch, down to 1900
  • represent validation bounds in local time to match parsed calendar dates
  • cover the exact lower boundary, 1900-01-01, in a positive UTC offset timezone

Closes #8681

Validation

  • flutter test --no-pub test/widget_test/date_picker_test.dart — 13 tests passed
  • flutter analyze --no-pub . — no issues found
  • Dart formatting and git diff --check pass

Validated with Flutter 3.27.4 on macOS arm64 (UTC+08:00).

@sourcery-ai

sourcery-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Expands date picker support to historical dates by changing the lower boundary from 1970 to 1900 and adds widget coverage proving that a 1958 date can be entered and stored consistently with the picker boundary.

Flow diagram for historical date selection

flowchart LR
    Input["User enters or selects a date"] --> Boundary["Date picker boundary: 1900-2100"]
    Boundary --> Valid["1958 date accepted"]
    Valid --> Stored["Date stored consistently"]
Loading

File-Level Changes

Change Details Files
Moves the date picker’s earliest selectable date from the Unix epoch back to 1900.
  • Updates the calendar lower-bound constant to DateTime.utc(1900).
  • Retains the existing 2100 upper bound while documenting the historical-date rationale.
frontend/appflowy_flutter/lib/workspace/presentation/widgets/date_picker/widgets/date_picker.dart
Adds regression coverage for selecting and validating a pre-epoch date through the date picker.
  • Verifies the calendar exposes 1900 as its first day.
  • Enters and submits January 25, 1958 through the date field.
  • Confirms the resulting application state contains the expected date.
frontend/appflowy_flutter/test/widget_test/date_picker_test.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#8681 Allow the date picker to select dates before the Unix epoch, including dates such as 25 January 1958.
#8681 Keep text-based date entry validation consistent with the date picker's supported date range.
#8681 Add regression coverage confirming that a pre-1970 date can be entered and stored correctly.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="frontend/appflowy_flutter/lib/workspace/presentation/widgets/date_picker/widgets/date_picker.dart" line_range="7-10" />
<code_context>
 import 'package:table_calendar/table_calendar.dart';
 import 'package:universal_platform/universal_platform.dart';

-final kFirstDay = DateTime.utc(1970);
+// Dates are also used for values such as birthdays, which can predate Unix
+// epoch. Keep the lower bound broad enough for historical dates while avoiding
+// the impractically large range before the Gregorian calendar.
+final kFirstDay = DateTime.utc(1900);
 final kLastDay = DateTime.utc(2100);

</code_context>
<issue_to_address>
**issue (bug_risk):** The UTC lower bound is compared with local `DateTime` values, so users in time zones east of UTC cannot enter or select 1 January 1900: local midnight is still 31 December 1899 UTC and is treated as before `kFirstDay`. The same date-only boundary mismatch affects the text-field validation that reuses this constant.

**Triggers:** When the user selects or enters the first day of the newly supported range in a positive-UTC-offset timezone.

**Suggested fix:** Compare date components rather than instants, or define the boundary in the same local date representation used by parsed and calendar dates.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Date field can't go further back past 1970 (needed for inclusion of dates of birth)

2 participants