1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- import 'utils.dart' ;
16-
1715import '../clock.dart' ;
1816import 'stopwatch.dart' ;
17+ import 'utils.dart' ;
1918
2019/// A provider for the "current time" and points relative to the current time.
2120///
@@ -34,7 +33,9 @@ class Clock {
3433
3534 /// Creates a clock based on the given [currentTime] , or on the system clock
3635 /// by default.
37- const Clock ([DateTime currentTime () = systemTime]) : _time = currentTime;
36+ // ignore: deprecated_member_use_from_same_package
37+ const Clock ([DateTime Function () currentTime = systemTime])
38+ : _time = currentTime;
3839
3940 /// Creates [Clock] that always considers the current time to be [time] .
4041 Clock .fixed (DateTime time) : _time = (() => time);
@@ -52,13 +53,13 @@ class Clock {
5253 ///
5354 /// The amount of time is the sum of the individual parts.
5455 DateTime ago (
55- {int days: 0 ,
56- int hours: 0 ,
57- int minutes: 0 ,
58- int seconds: 0 ,
59- int milliseconds: 0 ,
60- int microseconds: 0 }) =>
61- agoBy (new Duration (
56+ {int days = 0 ,
57+ int hours = 0 ,
58+ int minutes = 0 ,
59+ int seconds = 0 ,
60+ int milliseconds = 0 ,
61+ int microseconds = 0 }) =>
62+ agoBy (Duration (
6263 days: days,
6364 hours: hours,
6465 minutes: minutes,
@@ -70,13 +71,13 @@ class Clock {
7071 ///
7172 /// The amount of time is the sum of the individual parts.
7273 DateTime fromNow (
73- {int days: 0 ,
74- int hours: 0 ,
75- int minutes: 0 ,
76- int seconds: 0 ,
77- int milliseconds: 0 ,
78- int microseconds: 0 }) =>
79- fromNowBy (new Duration (
74+ {int days = 0 ,
75+ int hours = 0 ,
76+ int minutes = 0 ,
77+ int seconds = 0 ,
78+ int milliseconds = 0 ,
79+ int microseconds = 0 }) =>
80+ fromNowBy (Duration (
8081 days: days,
8182 hours: hours,
8283 minutes: minutes,
@@ -137,7 +138,7 @@ class Clock {
137138 var month = (time.month - months - 1 ) % 12 + 1 ;
138139 var year = time.year - (months + 12 - time.month) ~ / 12 ;
139140 var day = clampDayOfMonth (year: year, month: month, day: time.day);
140- return new DateTime (year, month, day, time.hour, time.minute, time.second,
141+ return DateTime (year, month, day, time.hour, time.minute, time.second,
141142 time.millisecond);
142143 }
143144
@@ -150,7 +151,7 @@ class Clock {
150151 var month = (time.month + months - 1 ) % 12 + 1 ;
151152 var year = time.year + (months + time.month - 1 ) ~ / 12 ;
152153 var day = clampDayOfMonth (year: year, month: month, day: time.day);
153- return new DateTime (year, month, day, time.hour, time.minute, time.second,
154+ return DateTime (year, month, day, time.hour, time.minute, time.second,
154155 time.millisecond);
155156 }
156157
@@ -162,8 +163,8 @@ class Clock {
162163 var time = now ();
163164 var year = time.year - years;
164165 var day = clampDayOfMonth (year: year, month: time.month, day: time.day);
165- return new DateTime (year, time.month, day, time.hour, time.minute,
166- time.second, time. millisecond);
166+ return DateTime (year, time.month, day, time.hour, time.minute, time.second ,
167+ time.millisecond);
167168 }
168169
169170 /// Return the point in time [years] from now on the same date.
@@ -172,10 +173,10 @@ class Clock {
172173 /// valid day in the original month will be used.
173174 DateTime yearsFromNow (int years) => yearsAgo (- years);
174175
175- /// Returns a new stopwatch that uses the current time as reported by [ this] .
176- Stopwatch stopwatch () => new ClockStopwatch (this );
176+ /// Returns a new stopwatch that uses the current time as reported by ` this` .
177+ Stopwatch stopwatch () => ClockStopwatch (this );
177178
178- /// Returns a new stopwatch that uses the current time as reported by [ this] .
179+ /// Returns a new stopwatch that uses the current time as reported by ` this` .
179180 @Deprecated ("Use stopwatch() instead." )
180181 Stopwatch getStopwatch () => stopwatch ();
181182}
0 commit comments