| Category | Functions | 
|---|---|
| Main date types | Date DateTime | 
| Other date types | Month DayOfWeek TimeOfDay | 
| Date checking | valid validTimeUnits yearIsLeapYear isTimePoint enforceValid | 
| Date conversion | daysToDayOfWeek monthsToMonth | 
| Time units | cmpTimeUnits timeStrings | 
| Other | AllowDayOverflow DateTimeException | 
| Category | Functions | 
|---|---|
| Main types | Interval Direction | 
| Special intervals | everyDayOfWeek everyMonth everyDuration | 
| Special intervals | NegInfInterval PosInfInterval | 
| Underlying ranges | IntervalRange NegInfIntervalRange PosInfIntervalRange | 
| Flags | PopFirst | 
Module containing some basic benchmarking and timing functionality.
| Category | Functions | 
|---|---|
| Time zones | TimeZone UTC LocalTime PosixTimeZone WindowsTimeZone SimpleTimeZone | 
| Utilities | clearTZEnvVar parseTZConversions setTZEnvVar TZConversions | 
Get the current time from the system clock.
import std.datetime.systime : SysTime, Clock; SysTime currentTime = Clock.currTime();
Construct a specific point in time without timezone information and get its ISO string.
import std.datetime.date : DateTime; auto dt = DateTime(2018, 1, 1, 12, 30, 10); assert(dt.toISOString() == "20180101T123010"); assert(dt.toISOExtString() == "2018-01-01T12:30:10");
Construct a specific point in time in the UTC timezone and add two days.
import std.datetime.systime : SysTime; import std.datetime.timezone : UTC; import core.time : days; auto st = SysTime(DateTime(2018, 1, 1, 12, 30, 10), UTC()); assert(st.toISOExtString() == "2018-01-01T12:30:10Z"); st += 2.days; assert(st.toISOExtString() == "2018-01-03T12:30:10Z");
Phobos provides the following functionality for time:
This functionality is separated into the following modules: