Epoch time + msecs

Handyman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Nov 13 12:15:00 PST 2015


On Friday, 13 November 2015 at 18:27:42 UTC, Steven Schveighoffer 
wrote:
> On 11/13/15 1:00 PM, Handyman wrote:
> What I would do is this:
>
> auto t = (Clock.currTime() - 
> SysTime.fromUnixTime(0)).total!"msecs" / 1000.0

Thanks, Steve.

    import std.stdio;
    import std.datetime;

    void main() {
       auto t = (Clock.currTime() - 
SysTime.fromUnixTime(0)).total!"msecs" / 1000.0;
       writeln(t);
    }

Gives an error: Error: no property 'fromUnixTime' for type 
'SysTime'.

When I do

    auto t = (Clock.currTime() - 
unixTimeToStdTime(0)).total!"msecs" / 1000.0;

I get
Error: incompatible types for ((currTime(opCall())) - 
(unixTimeToStdTime(0))): 'SysTime' and 'long'

and when I do

auto t = (Clock.currTime() - 
SysTime.fromUnixTime(0)).total!"msecs" / 1000.0;

I get:
Error: no property 'fromUnixTime' for type 'SysTime'

I think I am spoiled by 'typeless' scriping languages.


More information about the Digitalmars-d-learn mailing list