View source code
Display the source code in std/datetime/systime.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Module std.datetime.systime
Example
Get the current time as a SysTime
import std .datetime .timezone : LocalTime;
SysTime today = Clock .currTime();
assert(today .timezone is LocalTime());
Example
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");
writeln(st); // SysTime(DateTime(2018, 1, 1, 10, 30, 0), UTC())
Example
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
writeln(ny .toISOString()); // "20180101T103000-05:00"
writeln(ny .toISOExtString()); // "2018-01-01T10:30:00-05:00"
Functions
Name | Description |
---|---|
DosFileTimeToSysTime(dft, tz)
|
Converts from DOS file date/time to SysTime .
|
FILETIMEToStdTime(ft)
|
This function is Windows-Only. |
FILETIMEToSysTime(ft, tz)
|
This function is Windows-Only. |
parseRFC822DateTime(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(stdTime)
|
This function is Windows-Only. |
stdTimeToUnixTime(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). |
SYSTEMTIMEToSysTime(st, tz)
|
This function is Windows-Only. |
SysTimeToDosFileTime(sysTime)
|
Converts from SysTime to DOS file date/time.
|
SysTimeToFILETIME(sysTime)
|
This function is Windows-Only. |
SysTimeToSYSTEMTIME(sysTime)
|
This function is Windows-Only. |
unixTimeToStdTime(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). |
Classes
Name | Description |
---|---|
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. |
Structs
Name | Description |
---|---|
SysTime
|
SysTime is the type used to get the current time from the
system or doing anything that involves time zones. Unlike
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.
|
Aliases
Name | Type | Description |
---|---|---|
DosFileTime
|
uint
|
Type representing the DOS file date/time format. |
Authors
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.