Phobos: Determining number of hours or minutes or seconds till now

rikki cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 19 19:48:14 PST 2017


On 20/01/2017 9:29 AM, Rene Zwanenburg wrote:
> On Thursday, 19 January 2017 at 14:04:36 UTC, aberba wrote:
>> Using the standard library, how do a get number of hours or seconds or
>> minutes or days or months or years till current time from a past
>> timestamp (like "2 mins ago")? Not with manual calculations but from
>> Phobos functions.
>
> You can get a duration by subtracting two timestamps. For example:
>
> auto delta = (Clock.currTime - timeStamp).total!"seconds";

As per the documentation this is wrong for anything beyond a few weeks.
Although I have no idea if that's the case implementation wise.


More information about the Digitalmars-d-learn mailing list