View source code
Display the source code in std/datetime/date.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.



Name Description
cmpTimeUnits Compares two time unit strings. "years" are the largest units and "hnsecs" are the smallest.
daysToDayOfWeek Returns the number of days from the current day of the week to the given day of the week. If they are the same, then the result is 0.
monthsToMonth Returns the number of months from the current months of the year to the given month of the year. If they are the same, then the result is 0.
valid Returns whether the given value is valid for the given unit type when in a time point. Naturally, a duration is not held to a particular range, but the values in a time point are (e.g. a month must be in the range of 1 - 12 inclusive).
valid Returns whether the given day is valid for the given year and month.
validTimeUnits Whether all of the given strings are valid units of time.
yearIsLeapYear Whether the given Gregorian Year is a leap year.


Name Description
Date Represents a date in the Proleptic Gregorian Calendar ranging from 32,768 B.C. to 32,767 A.D. Positive years are A.D. Non-positive years are B.C.
DateTime Combines the and structs to give an object which holds both the date and the time. It is optimized for calendar-based operations and has no concept of time zone. For an object which is optimized for time operations based on the system time, use std.datetime.systime.SysTime. std.datetime.systime.SysTime has a concept of time zone and has much higher precision (hnsecs). DateTime is intended primarily for calendar-based uses rather than precise time operations.
TimeOfDay Represents a time of day with hours, minutes, and seconds. It uses 24 hour time.


Name Description
DayOfWeek Represents the 7 days of the Gregorian week (Sunday is 0).
Month Represents the 12 months of the Gregorian year (January is 1).

Enum values

Name Type Description
CmpTimeUnits Compares two time unit strings at compile time. "years" are the largest units and "hnsecs" are the smallest.
isTimePoint Whether the given type defines all of the necessary functions for it to function as a time point.

Global variables

Name Type Description
timeStrings immutable(char[][]) Array of the strings representing time units, starting with the smallest unit and going to the largest. It does not include "nsecs".


Name Type Description
AllowDayOverflow Flag!("allowDayOverflow") In some date calculations, adding months or years can cause the date to fall on a day of the month which is not valid (e.g. February 29th 2001 or June 31st 2000). If overflow is allowed (as is the default), then the month will be incremented accordingly (so, February 29th 2001 would become March 1st 2001, and June 31st 2000 would become July 1st 2000). If overflow is not allowed, then the day will be adjusted to the last valid day in that month (so, February 29th 2001 would become February 28th 2001 and June 31st 2000 would become June 30th 2000).
DateTimeException TimeException Exception type used by std.datetime. It's an alias to core.time.TimeException. Either can be caught without concern about which module it came from.


Jonathan M Davis


Boost License 1.0.