Duration.total

Returns the total number of the given units in this Duration. So, unlike split, it does not strip out the larger units.

struct Duration
@safe pure @property
long
total
const nothrow @nogc
(
string units
)
()
if (
units == "weeks" ||
units == "days"
||
units == "hours"
||
units == "minutes"
||
units == "seconds"
||
units == "msecs"
||
units == "usecs"
||
units == "hnsecs"
||
units == "nsecs"
)

Examples

1 assert(dur!"weeks"(12).total!"weeks" == 12);
2 assert(dur!"weeks"(12).total!"days" == 84);
3 
4 assert(dur!"days"(13).total!"weeks" == 1);
5 assert(dur!"days"(13).total!"days" == 13);
6 
7 assert(dur!"hours"(49).total!"days" == 2);
8 assert(dur!"hours"(49).total!"hours" == 49);
9 
10 assert(dur!"nsecs"(2007).total!"hnsecs" == 20);
11 assert(dur!"nsecs"(2007).total!"nsecs" == 2000);
Suggestion Box / Bug Report