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
8252296a
Unverified
Commit
8252296a
authored
Jun 04, 2021
by
Darren Austin
Committed by
GitHub
Jun 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed TimeOfDay.hourOfPeriod for the noon and midnight cases. (#83947)
parent
ca789bf5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
time.dart
packages/flutter/lib/src/material/time.dart
+3
-1
time_test.dart
packages/flutter/test/material/time_test.dart
+28
-0
No files found.
packages/flutter/lib/src/material/time.dart
View file @
8252296a
...
...
@@ -92,7 +92,9 @@ class TimeOfDay {
DayPeriod
get
period
=>
hour
<
hoursPerPeriod
?
DayPeriod
.
am
:
DayPeriod
.
pm
;
/// Which hour of the current period (e.g., am or pm) this time is.
int
get
hourOfPeriod
=>
hour
-
periodOffset
;
///
/// For 12AM (midnight) and 12PM (noon) this returns 12.
int
get
hourOfPeriod
=>
hour
==
0
||
hour
==
12
?
12
:
hour
-
periodOffset
;
/// The hour at which the current period starts.
int
get
periodOffset
=>
period
==
DayPeriod
.
am
?
0
:
hoursPerPeriod
;
...
...
packages/flutter/test/material/time_test.dart
View file @
8252296a
...
...
@@ -27,6 +27,34 @@ void main() {
});
});
testWidgets
(
'hourOfPeriod returns correct value'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/59158.
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
0
).
hourOfPeriod
,
12
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
1
).
hourOfPeriod
,
1
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
2
).
hourOfPeriod
,
2
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
3
).
hourOfPeriod
,
3
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
4
).
hourOfPeriod
,
4
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
5
).
hourOfPeriod
,
5
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
6
).
hourOfPeriod
,
6
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
7
).
hourOfPeriod
,
7
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
8
).
hourOfPeriod
,
8
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
9
).
hourOfPeriod
,
9
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
10
).
hourOfPeriod
,
10
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
11
).
hourOfPeriod
,
11
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
12
).
hourOfPeriod
,
12
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
13
).
hourOfPeriod
,
1
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
14
).
hourOfPeriod
,
2
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
15
).
hourOfPeriod
,
3
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
16
).
hourOfPeriod
,
4
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
17
).
hourOfPeriod
,
5
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
18
).
hourOfPeriod
,
6
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
19
).
hourOfPeriod
,
7
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
20
).
hourOfPeriod
,
8
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
21
).
hourOfPeriod
,
9
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
22
).
hourOfPeriod
,
10
);
expect
(
const
TimeOfDay
(
minute:
0
,
hour:
23
).
hourOfPeriod
,
11
);
});
group
(
'RestorableTimeOfDay tests'
,
()
{
testWidgets
(
'value is not accessible when not registered'
,
(
WidgetTester
tester
)
async
{
expect
(()
=>
RestorableTimeOfDay
(
const
TimeOfDay
(
hour:
20
,
minute:
4
)).
value
,
throwsAssertionError
);
...
...
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