Merge pull request #220 from cbracken/dartformat_cleanups
Reformat with dartformat
diff --git a/lib/clock.dart b/lib/clock.dart
index ddef5a7..dcc8a2c 100644
--- a/lib/clock.dart
+++ b/lib/clock.dart
@@ -23,11 +23,10 @@
/// Days in a month. This array uses 1-based month numbers, i.e. January is
/// the 1-st element in the array, not the 0-th.
const _DAYS_IN_MONTH =
- const [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
+ const [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
-int _daysInMonth(int year, int month) =>
- (month == DateTime.FEBRUARY && _isLeapYear(year))
- ? 29 : _DAYS_IN_MONTH[month];
+int _daysInMonth(int year, int month) => (month == DateTime.FEBRUARY &&
+ _isLeapYear(year)) ? 29 : _DAYS_IN_MONTH[month];
bool _isLeapYear(int year) =>
(year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0));
@@ -58,7 +57,6 @@
/// exactly what time a [Clock] returns and base your test expectations on
/// that. See specific constructors for how to supply time functions.
class Clock {
-
final TimeFunction _time;
/// Creates a clock based on the given [timeFunc].
@@ -85,34 +83,26 @@
/// Returns the point in time that's given amount of time ago. The
/// amount of time is the sum of individual parts. Parts are compatible with
/// ones defined in [Duration].
- DateTime ago({int days: 0,
- int hours: 0,
- int minutes: 0,
- int seconds: 0,
- int milliseconds: 0,
- int microseconds: 0}) =>
- agoBy(new Duration(days: days,
- hours: hours,
- minutes: minutes,
- seconds: seconds,
- milliseconds: milliseconds,
- microseconds: microseconds));
+ DateTime ago({int days: 0, int hours: 0, int minutes: 0, int seconds: 0,
+ int milliseconds: 0, int microseconds: 0}) => agoBy(new Duration(
+ days: days,
+ hours: hours,
+ minutes: minutes,
+ seconds: seconds,
+ milliseconds: milliseconds,
+ microseconds: microseconds));
/// Returns the point in time that's given amount of time from now. The
/// amount of time is the sum of individual parts. Parts are compatible with
/// ones defined in [Duration].
- DateTime fromNow({int days: 0,
- int hours: 0,
- int minutes: 0,
- int seconds: 0,
- int milliseconds: 0,
- int microseconds: 0}) =>
- fromNowBy(new Duration(days: days,
- hours: hours,
- minutes: minutes,
- seconds: seconds,
- milliseconds: milliseconds,
- microseconds: microseconds));
+ DateTime fromNow({int days: 0, int hours: 0, int minutes: 0, int seconds: 0,
+ int milliseconds: 0, int microseconds: 0}) => fromNowBy(new Duration(
+ days: days,
+ hours: hours,
+ minutes: minutes,
+ seconds: seconds,
+ milliseconds: milliseconds,
+ microseconds: microseconds));
/// Return the point in time [micros] microseconds ago.
DateTime microsAgo(int micros) => ago(microseconds: micros);
@@ -163,14 +153,7 @@
var y = time.year - (months + 12 - time.month) ~/ 12;
var d = _clampDate(time.day, y, m);
return new DateTime(
- y,
- m,
- d,
- time.hour,
- time.minute,
- time.second,
- time.millisecond
- );
+ y, m, d, time.hour, time.minute, time.second, time.millisecond);
}
/// Return the point in time [months] from now on the same date.
@@ -180,14 +163,7 @@
var y = time.year + (months + time.month - 1) ~/ 12;
var d = _clampDate(time.day, y, m);
return new DateTime(
- y,
- m,
- d,
- time.hour,
- time.minute,
- time.second,
- time.millisecond
- );
+ y, m, d, time.hour, time.minute, time.second, time.millisecond);
}
/// Return the point in time [years] ago on the same date.
@@ -195,15 +171,8 @@
var time = now();
var y = time.year - years;
var d = _clampDate(time.day, y, time.month);
- return new DateTime(
- y,
- time.month,
- d,
- time.hour,
- time.minute,
- time.second,
- time.millisecond
- );
+ return new DateTime(y, time.month, d, time.hour, time.minute, time.second,
+ time.millisecond);
}
/// Return the point in time [years] from now on the same date.
diff --git a/test/clock_test.dart b/test/clock_test.dart
index 09ea399..0e12357 100644
--- a/test/clock_test.dart
+++ b/test/clock_test.dart
@@ -40,12 +40,11 @@
test('should be close enough to system clock', () {
// At 10ms the test doesn't seem to be flaky.
var epsilon = 10;
- expect(new DateTime.now().difference(
- new Clock().now()).inMilliseconds.abs(),
- lessThan(epsilon));
- expect(new DateTime.now().difference(
- const Clock().now()).inMilliseconds.abs(),
- lessThan(epsilon));
+ expect(
+ new DateTime.now().difference(new Clock().now()).inMilliseconds.abs(),
+ lessThan(epsilon));
+ expect(new DateTime.now().difference(const Clock().now()).inMilliseconds
+ .abs(), lessThan(epsilon));
});
test('should return time provided by custom TimeFunction', () {
@@ -90,53 +89,47 @@
});
test('should return time micros ago', () {
- expect(subject.microsAgo(1000),
- new DateTime(2012, 12, 31, 23, 59, 59, 999));
+ expect(
+ subject.microsAgo(1000), new DateTime(2012, 12, 31, 23, 59, 59, 999));
});
test('should return time micros from now', () {
- expect(subject.microsFromNow(1000),
- new DateTime(2013, 1, 1, 0, 0, 0, 1));
+ expect(subject.microsFromNow(1000), new DateTime(2013, 1, 1, 0, 0, 0, 1));
});
test('should return time millis ago', () {
- expect(subject.millisAgo(1000),
- new DateTime(2012, 12, 31, 23, 59, 59, 000));
+ expect(
+ subject.millisAgo(1000), new DateTime(2012, 12, 31, 23, 59, 59, 000));
});
test('should return time millis from now', () {
- expect(subject.millisFromNow(3),
- new DateTime(2013, 1, 1, 0, 0, 0, 3));
+ expect(subject.millisFromNow(3), new DateTime(2013, 1, 1, 0, 0, 0, 3));
});
test('should return time seconds ago', () {
- expect(subject.secondsAgo(10),
- new DateTime(2012, 12, 31, 23, 59, 50, 000));
+ expect(
+ subject.secondsAgo(10), new DateTime(2012, 12, 31, 23, 59, 50, 000));
});
test('should return time seconds from now', () {
- expect(subject.secondsFromNow(3),
- new DateTime(2013, 1, 1, 0, 0, 3, 0));
+ expect(subject.secondsFromNow(3), new DateTime(2013, 1, 1, 0, 0, 3, 0));
});
test('should return time minutes ago', () {
- expect(subject.minutesAgo(10),
- new DateTime(2012, 12, 31, 23, 50, 0, 000));
+ expect(
+ subject.minutesAgo(10), new DateTime(2012, 12, 31, 23, 50, 0, 000));
});
test('should return time minutes from now', () {
- expect(subject.minutesFromNow(3),
- new DateTime(2013, 1, 1, 0, 3, 0, 0));
+ expect(subject.minutesFromNow(3), new DateTime(2013, 1, 1, 0, 3, 0, 0));
});
test('should return time hours ago', () {
- expect(subject.hoursAgo(10),
- new DateTime(2012, 12, 31, 14, 0, 0, 000));
+ expect(subject.hoursAgo(10), new DateTime(2012, 12, 31, 14, 0, 0, 000));
});
test('should return time hours from now', () {
- expect(subject.hoursFromNow(3),
- new DateTime(2013, 1, 1, 3, 0, 0, 0));
+ expect(subject.hoursFromNow(3), new DateTime(2013, 1, 1, 3, 0, 0, 0));
});
test('should return time days ago', () {
@@ -202,11 +195,11 @@
});
test('should return time years ago on the same date', () {
- expectDate(subject.yearsAgo(1), 2012, 1, 1); // leap year
+ expectDate(subject.yearsAgo(1), 2012, 1, 1); // leap year
expectDate(subject.yearsAgo(2), 2011, 1, 1);
expectDate(subject.yearsAgo(3), 2010, 1, 1);
expectDate(subject.yearsAgo(4), 2009, 1, 1);
- expectDate(subject.yearsAgo(5), 2008, 1, 1); // leap year
+ expectDate(subject.yearsAgo(5), 2008, 1, 1); // leap year
expectDate(subject.yearsAgo(6), 2007, 1, 1);
expectDate(subject.yearsAgo(30), 1983, 1, 1);
expectDate(subject.yearsAgo(2013), 0, 1, 1);
@@ -222,6 +215,5 @@
expectDate(subject.yearsFromNow(30), 2043, 1, 1);
expectDate(subject.yearsFromNow(1000), 3013, 1, 1);
});
-
});
}