Permalink
Browse files

Implement issue# 9337: There's no Duration.max.

Added Duration.max and Duration.min.
  • Loading branch information...
1 parent e1d9e4d commit 606a6e52c488051708259e6834595c938ad97b8b jmdavis committed Jan 18, 2013
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/core/time.d
View
18 src/core/time.d
@@ -115,11 +115,29 @@ public:
+/
static @property @safe pure nothrow Duration zero() { return Duration(0); }
+ /++
+ Largest $(D Duration) possible.
+ +/
+ static @property @safe pure nothrow Duration max() { return Duration(long.max); }
+
+ /++
+ Most negative $(D Duration) possible.
+ +/
+ static @property @safe pure nothrow Duration min() { return Duration(long.min); }
+
unittest
{
assert(zero == dur!"seconds"(0));
+ assert(Duration.max == Duration(long.max));
+ assert(Duration.min == Duration(long.min));
+ assert(Duration.min < Duration.zero);
+ assert(Duration.zero < Duration.max);
+ assert(Duration.min < Duration.max);
+ assert(Duration.min - dur!"hnsecs"(1) == Duration.max);
+ assert(Duration.max + dur!"hnsecs"(1) == Duration.min);
}
+
/++
Compares this $(D Duration) with the given $(D Duration).

0 comments on commit 606a6e5

Please sign in to comment.