On Tue, 06 Mar 2012 12:09:47 -0500, Andrej Mitrovic <andrej.mitrov...@gmail.com> wrote:

I'll never forgive std.datetime for this mistake:

auto sw = StopWatch(AutoStart.yes);
writeln(sw.peek.hnsecs);
writeln(sw.peek.nsecs);
writeln(sw.peek.usecs);
writeln(sw.peek.msecs);
writeln(sw.peek.secs);  // bzzzzz NOPE
writeln(sw.peek.seconds);

I misspell this thing every single time I use stopwatch to count seconds.

this is a no-brainer:

Duration dur(string units)(long length) @safe pure nothrow
    if(units == "weeks" ||
       units == "days" ||
       units == "hours" ||
       units == "minutes" ||
       units == "seconds" ||
       units == "secs" || // added
       units == "msecs" ||
       units == "usecs" ||
       units == "hnsecs" ||
       units == "nsecs")
{
    return Duration(convert!(units, "hnsecs")(length));
}

// etc, everywhere "seconds" is used, add "secs" as well.

I'll see if I can do a pull request.

-Steve

Reply via email to