std.datetime.date

Members

Aliases

AllowDayOverflow
alias 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
alias 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.

Enums

DayOfWeek
enum DayOfWeek

Represents the 7 days of the Gregorian week (Sunday is 0).

Month
enum Month

Represents the 12 months of the Gregorian year (January is 1).

Functions

cmpTimeUnits
int cmpTimeUnits(string lhs, string rhs)

Compares two time unit strings. "years" are the largest units and "hnsecs" are the smallest.

daysToDayOfWeek
int daysToDayOfWeek(DayOfWeek currDoW, DayOfWeek dow)

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.

enforceValid
void enforceValid(int value, string file, size_t line)
enforceValid
void enforceValid(int year, Month month, int day, string file, size_t line)

Because the validity of the day number depends on both on the year and month of which the day is occurring, take all three variables to validate the day.

monthsToMonth
int monthsToMonth(int currMonth, int month)

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
bool valid(int value)

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
bool valid(int year, int month, int day)

Returns whether the given day is valid for the given year and month.

validTimeUnits
bool validTimeUnits(string[] units)

Whether all of the given strings are valid units of time.

yearIsLeapYear
bool yearIsLeapYear(int year)

Whether the given Gregorian Year is a leap year.

Structs

Date
struct 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
struct DateTime

Combines the std.datetime.date.Date and std.datetime.date.TimeOfDay 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
struct TimeOfDay

Represents a time of day with hours, minutes, and seconds. It uses 24 hour time.

Templates

CmpTimeUnits
template CmpTimeUnits(string lhs, string rhs)

Compares two time unit strings at compile time. "years" are the largest units and "hnsecs" are the smallest.

isTimePoint
template isTimePoint(T)

Whether the given type defines all of the necessary functions for it to function as a time point.

Variables

timeStrings
string[] timeStrings;

Array of the strings representing time units, starting with the smallest unit and going to the largest. It does not include "nsecs".

Meta