best D equivalent to C'stimeval

Jonathan M Davis jmdavisProg at gmx.com
Sun Mar 30 23:25:25 PDT 2014


On Monday, March 31, 2014 05:09:22 ed wrote:
> Hi,
> 
> Just wondering what the best replacement for C timeval is in D.
> I'm looking at std.datetime.SysTime, but std.datetime is huge so
> I'm not sure.

If you want an overview of std.datetime, read

http://dlang.org/intro-to-datetime.html

But yes, SysTime would be what you'd want to use instead of a timeval. SysTime 
is intended for representing the time of the system, whereas DateTime, Date, 
or TimeOfDay relate to specifically to calendar time (they have no time zones 
and therefore cannot be tied to a unique point in time - e.g. a DateTime for 
2014-03-30T12:00:00 could be one of over 24 different points in time, as it 
has no time zone to tie it down). SysTime holds its time internally in UTC and 
uses a TimeZone object to convert to to other time zones when required (e.g. 
when printing it out); it defaults to LocalTime, which represents the local 
time of your system.

SysTime also has a function called toTimeVal for converting to a timeval if 
you need to pass it to C code.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list