Category | Functions |
---|---|
Types | Clock SysTime DosFileTime |
Conversion | parseRFC822DateTime DosFileTimeToSysTime FILETIMEToStdTime FILETIMEToSysTime stdTimeToFILETIME stdTimeToUnixTime SYSTEMTIMEToSysTime SysTimeToDosFileTime SysTimeToFILETIME SysTimeToSYSTEMTIME unixTimeToStdTime |
Type representing the DOS file date/time format.
Effectively a namespace to make it clear that the methods it contains are getting the time from the system clock. It cannot be instantiated.
Converts from DOS file date/time to SysTime.
This function is Windows-Only.
This function is Windows-Only.
This function is Windows-Only.
Converts from SysTime to DOS file date/time.
This function is Windows-Only.
This function is Windows-Only.
This function is Windows-Only.
Converts std time (which uses midnight, January 1st, 1 A.D. UTC as its epoch and hnsecs as its units) to unix time (which uses midnight, January 1st, 1970 UTC as its epoch and seconds as its units).
Converts from unix time (which uses midnight, January 1st, 1970 UTC as its epoch and seconds as its units) to "std time" (which uses midnight, January 1st, 1 A.D. UTC and hnsecs as its units).
SysTime is the type used to get the current time from the system or doing anything that involves time zones. Unlike std.datetime.date.DateTime, the time zone is an integral part of SysTime (though for local time applications, time zones can be ignored and it will work, since it defaults to using the local time zone). It holds its internal time in std time (hnsecs since midnight, January 1st, 1 A.D. UTC), so it interfaces well with the system time.
Get the current time as a SysTime
import std.datetime.timezone : LocalTime; SysTime today = Clock.currTime(); assert(today.timezone is LocalTime());
Construct a SysTime from a ISO time string
import std.datetime.date : DateTime; import std.datetime.timezone : UTC; auto st = SysTime.fromISOExtString("2018-01-01T10:30:00Z"); assert(st == SysTime(DateTime(2018, 1, 1, 10, 30, 0), UTC()));
Make a specific point in time in the New York timezone
import core.time : hours; import std.datetime.date : DateTime; import std.datetime.timezone : SimpleTimeZone; auto ny = SysTime( DateTime(2018, 1, 1, 10, 30, 0), new immutable SimpleTimeZone(-5.hours, "America/New_York") ); // ISO standard time strings assert(ny.toISOString() == "20180101T103000-05:00"); assert(ny.toISOExtString() == "2018-01-01T10:30:00-05:00");