On Friday, 4 October 2013 at 21:54:19 UTC, Brad Anderson wrote:
On Friday, 4 October 2013 at 21:50:31 UTC, Brad Anderson wrote:
On Friday, 4 October 2013 at 21:46:43 UTC, JohnnyK wrote:
Hi All,
I did search but I cannot find it anywhere. All I want to do is add 300 seconds to the output of Clock.currTime. So basically if Clock.currTime equals 2013-Oct-04 17:19:31.3338333 then I want to subtract 300 seconds from that to get the time that it was 300 seconds ago. In other languages I would convert the time value to seconds and subtract the 300 seconds then convert it back to what ever time value it was before. I don't know how to convert 300 seconds to hnsecs and I have never actually heard of hnsecs before. Anyway if someone could help I would appreciate it.

auto t = Clock.currTime;
t -= 300.seconds;
t += 300.seconds;

And just a little bit more info, another way to write this is:

auto t = Clock.currTime;
t -= seconds(300);
t += seconds(300);

The first way I wrote is just the UFCS version of that.

You could also do:

auto t = Clock.currTime;
t -= dur!"seconds"(300);
t += dur!"seconds"(300);

seconds() is just an alias for the dur template with the "seconds" template argument.

Wow I appreciate the quick response. Ok I have seen this before. What is the dur? Where is dur defined? Also I am confused how 300.seconds would work. How can a literal number have properties?

Reply via email to