mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 08:46:18 +01:00
Add convenient extensions for DateTime
This commit is contained in:
parent
6281e6daff
commit
b1f975c329
2 changed files with 14 additions and 0 deletions
|
@ -2,3 +2,4 @@ library np_datetime;
|
|||
|
||||
export 'src/date.dart';
|
||||
export 'src/time_range.dart';
|
||||
export 'src/util.dart';
|
||||
|
|
13
np_datetime/lib/src/util.dart
Normal file
13
np_datetime/lib/src/util.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
extension DateTimeExtension on DateTime {
|
||||
/// Returns true if [this] occurs before or at the same moment as [other].
|
||||
///
|
||||
/// The comparison is independent
|
||||
/// of whether the time is in UTC or in the local time zone.
|
||||
bool isBeforeOrAt(DateTime other) => !isAfter(other);
|
||||
|
||||
/// Returns true if [this] occurs after or at the same moment as [other].
|
||||
///
|
||||
/// The comparison is independent
|
||||
/// of whether the time is in UTC or in the local time zone.
|
||||
bool isAfterOrAt(DateTime other) => !isBefore(other);
|
||||
}
|
Loading…
Reference in a new issue