time difference - beautify my code
dd0s via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 2 12:03:48 PDT 2015
i got a date t described in seconds from 1.1.1970, and i want to
check if the current time is further than 12 hours from the given
time t. the following code works but it's super ugly =S
please give me some ideas how to make this code nicer :)
private static bool sessionIsCurrent(long t)
{
DateTime dateTime = DateTime(1970, 1, 1) +
dur!"msecs"(t*1000);
DateTime curTime = DateTime() +
dur!"hnsecs"(Clock.currStdTime());
return (curTime - dateTime) < dur!"msecs"(1000*60*60*12);
}
thx for your effort
More information about the Digitalmars-d-learn
mailing list