The OpenD Programming Language

std.datetime.systime

Members

Aliases

DosFileTime
alias DosFileTime = uint

Type representing the DOS file date/time format.

Classes

Clock
class Clock

Effectively a namespace to make it clear that the methods it contains are getting the time from the system clock. It cannot be instantiated.

Functions

DosFileTimeToSysTime
SysTime DosFileTimeToSysTime(DosFileTime dft, TimeZone tz)

Converts from DOS file date/time to SysTime.

FILETIMEToStdTime
long FILETIMEToStdTime(FILETIME* ft)

This function is Windows-Only.

FILETIMEToSysTime
SysTime FILETIMEToSysTime(FILETIME* ft, TimeZone tz)

This function is Windows-Only.

SYSTEMTIMEToSysTime
SysTime SYSTEMTIMEToSysTime(SYSTEMTIME* st, TimeZone tz)

This function is Windows-Only.

SysTimeToDosFileTime
DosFileTime SysTimeToDosFileTime(SysTime sysTime)

Converts from SysTime to DOS file date/time.

SysTimeToFILETIME
FILETIME SysTimeToFILETIME(SysTime sysTime)

This function is Windows-Only.

SysTimeToSYSTEMTIME
SYSTEMTIME SysTimeToSYSTEMTIME(SysTime sysTime)

This function is Windows-Only.

parseRFC822DateTime
SysTime parseRFC822DateTime(char[] value)
SysTime parseRFC822DateTime(R value)

The given array of char or random-access range of char or ubyte is expected to be in the format specified in RFC 5322 section 3.3 with the grammar rule date-time. It is the date-time format commonly used in internet messages such as e-mail and HTTP. The corresponding SysTime will be returned.

stdTimeToFILETIME
FILETIME stdTimeToFILETIME(long stdTime)

This function is Windows-Only.

stdTimeToUnixTime
T stdTimeToUnixTime(long stdTime)

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).

unixTimeToStdTime
long unixTimeToStdTime(long unixTime)

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).

Structs

SysTime
struct SysTime

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.

Examples

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");

Meta