www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Compare times: file modification time

reply Martin Tschierschke <mt smartdolphin.de> writes:
With

import std.file:timeLastModified;
auto time = timeLastModified(source);

I get a SysTime, how to check if it is older than an interval (1 
day)?
D/Phobos idiomatically?

(Currently I am using 
(Clock.currTime().toUnixTime-time.toUnixTime)< 60*60*24)).

Regards mt.
Aug 02 2017
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Wednesday, 2 August 2017 at 13:25:25 UTC, Martin Tschierschke 
wrote:
 I get a SysTime, how to check if it is older than an interval 
 (1 day)?
 D/Phobos idiomatically?
if(Clock.currTime - timeLastModified("aa.d") > 1.days) { // older }
Aug 02 2017
parent Martin Tschierschke <mt smartdolphin.de> writes:
On Wednesday, 2 August 2017 at 13:32:46 UTC, Adam D. Ruppe wrote:
 On Wednesday, 2 August 2017 at 13:25:25 UTC, Martin 
 Tschierschke wrote:
 I get a SysTime, how to check if it is older than an interval 
 (1 day)?
 D/Phobos idiomatically?
if(Clock.currTime - timeLastModified("aa.d") > 1.days) { // older }
Thank you Adam. So simple!
Aug 02 2017