Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
812c189d
Unverified
Commit
812c189d
authored
Jun 29, 2020
by
Darren Austin
Committed by
GitHub
Jun 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a problem with date calculations that caused a test to fail in a non-US time zone. (#60396)
parent
c0902d60
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
calendar_date_picker.dart
...lutter/lib/src/material/pickers/calendar_date_picker.dart
+8
-8
date_utils.dart
packages/flutter/lib/src/material/pickers/date_utils.dart
+5
-0
No files found.
packages/flutter/lib/src/material/pickers/calendar_date_picker.dart
View file @
812c189d
...
...
@@ -668,14 +668,14 @@ class _MonthPickerState extends State<_MonthPicker> {
});
}
static
const
Map
<
TraversalDirection
,
Duration
>
_directionOffset
=
<
TraversalDirection
,
Duration
>{
TraversalDirection
.
up
:
Duration
(
days:
-
DateTime
.
daysPerWeek
)
,
TraversalDirection
.
right
:
Duration
(
days:
1
)
,
TraversalDirection
.
down
:
D
uration
(
days:
DateTime
.
daysPerWeek
)
,
TraversalDirection
.
left
:
Duration
(
days:
-
1
)
,
static
const
Map
<
TraversalDirection
,
int
>
_directionOffset
=
<
TraversalDirection
,
int
>{
TraversalDirection
.
up
:
-
DateTime
.
daysPerWeek
,
TraversalDirection
.
right
:
1
,
TraversalDirection
.
down
:
D
ateTime
.
daysPerWeek
,
TraversalDirection
.
left
:
-
1
,
};
Duration
_dayDirectionOffset
(
TraversalDirection
traversalDirection
,
TextDirection
textDirection
)
{
int
_dayDirectionOffset
(
TraversalDirection
traversalDirection
,
TextDirection
textDirection
)
{
// Swap left and right if the text direction if RTL
if
(
textDirection
==
TextDirection
.
rtl
)
{
if
(
traversalDirection
==
TraversalDirection
.
left
)
...
...
@@ -688,12 +688,12 @@ class _MonthPickerState extends State<_MonthPicker> {
DateTime
_nextDateInDirection
(
DateTime
date
,
TraversalDirection
direction
)
{
final
TextDirection
textDirection
=
Directionality
.
of
(
context
);
DateTime
nextDate
=
date
.
toUtc
().
add
(
_dayDirectionOffset
(
direction
,
textDirection
));
DateTime
nextDate
=
utils
.
addDaysToDate
(
date
,
_dayDirectionOffset
(
direction
,
textDirection
));
while
(!
nextDate
.
isBefore
(
widget
.
firstDate
)
&&
!
nextDate
.
isAfter
(
widget
.
lastDate
))
{
if
(
_isSelectable
(
nextDate
))
{
return
nextDate
;
}
nextDate
=
nextDate
.
add
(
_dayDirectionOffset
(
direction
,
textDirection
));
nextDate
=
utils
.
addDaysToDate
(
nextDate
,
_dayDirectionOffset
(
direction
,
textDirection
));
}
return
null
;
}
...
...
packages/flutter/lib/src/material/pickers/date_utils.dart
View file @
812c189d
...
...
@@ -72,6 +72,11 @@ DateTime addMonthsToMonthDate(DateTime monthDate, int monthsToAdd) {
return
DateTime
(
monthDate
.
year
,
monthDate
.
month
+
monthsToAdd
);
}
/// Returns a [DateTime] with the added number of days and no time set.
DateTime
addDaysToDate
(
DateTime
date
,
int
days
)
{
return
DateTime
(
date
.
year
,
date
.
month
,
date
.
day
+
days
);
}
/// Computes the offset from the first day of the week that the first day of
/// the [month] falls on.
///
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment