fix: allow dates before unix epoch - #9000
Open
kaluli123123 wants to merge 3 commits into
Open
Conversation
Contributor
Reviewer's GuideExpands 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 selectionflowchart LR
Input["User enters or selects a date"] --> Boundary["Date picker boundary: 1900-2100"]
Boundary --> Valid["1958 date accepted"]
Valid --> Stored["Date stored consistently"]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
|
Contributor
There was a problem hiding this comment.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
1900-01-01, in a positive UTC offset timezoneCloses #8681
Validation
flutter test --no-pub test/widget_test/date_picker_test.dart— 13 tests passedflutter analyze --no-pub .— no issues foundgit diff --checkpassValidated with Flutter 3.27.4 on macOS arm64 (UTC+08:00).