View source code Display the source code in std/datetime.d from which this page was generated on github. 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. Page wiki View or edit the community-maintained wiki page associated with this page.

Function std.datetime.stdTimeToUnixTime

Converts std time (which uses midnight, January 1st, 1 A.D. UTC as its epoch and hnsecs as its units) to time_t (which uses midnight, January 1st, 1970 UTC as its epoch and seconds as its units). If time_t is 32 bits, rather than 64, and the result can't fit in a 32-bit value, then the closest value that can be held in 32 bits will be used (so time_t.max if it goes over and time_t.min if it goes under).

Prototype

long stdTimeToUnixTime(
  long stdTime
) pure nothrow @safe;

Note

While Windows systems require that time_t be non-negative (in spite of time_t being signed), this function still returns negative numbers on Windows, since it's more flexible to allow negative time_t for those who need it. If on Windows and using the standard C functions or Win32 API functions which take a time_t, check whether the return value of stdTimeToUnixTime is non-negative.

Parameters

NameDescription
stdTime The std time to convert.

Authors

Jonathan M Davis and Kato Shoichi

License

Boost License 1.0.

Comments