Convert SysTime to TickDuration?

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Nov 22 15:24:13 PST 2011


I need the number of ticks for a file's modification date.

module test;
import std.datetime;
import std.file;
import std.stdio;

void main()
{
    auto res1 = TickDuration(timeLastModified("test.d"));  // NG
    auto res2 = TickDuration.from!"hnsecs"(timeLastModified("test.d").stdTime);
    writeln(res2);
}

First one doesn't work, and it's really a pain having to find all
these from/to/convert methods just to convert one value to another.

The second one returns a negative number, but I can't tell whether
this is right. Isn't the tick count supposed to be positive?

Tango had this method:
Path.modified(m.path).ticks;

Very simple there.


More information about the Digitalmars-d-learn mailing list