How to get current time as long or ulong?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 5 11:53:26 PDT 2016


On Tuesday, July 05, 2016 11:43:32 Jonathan M Davis via Digitalmars-d-learn 
wrote:
> But if what you want is a time_t, and you don't want to deal with SysTime,
> there's no point in using std.datetime. Just use core.time to call C's time
> function.

Actually, I should qualify this. I keep forgetting that time_t is not
guaranteed to be unix time on non-POSIX systems. If what you want is time_t,
then use C's time function via core.time, but if what you want is actual
unix time, then just do Clock.currTime.toUnixTime, since that's the simplest
way to do it. If you're using Microsoft's runtime, then time_t is indeed
unix time, but it's not for the Digital Mars runtime (and the standard -
unfortunately - doesn't require it to be). Digital Mars uses someting that's
_close_ to time_t but isn't actually time_t. :(

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list