The OpenD Programming Language

mir.date

Fast BetterC Date type with Boost ABI and mangling compatability.

CategoryFunctions
Main date typesDate YearMonth YearQuarter
Other date typesMonth Quarter DayOfWeek
Date checkingvalid yearIsLeapYear
Date conversiondaysToDayOfWeek quarter
OtherAllowDayOverflow DateTimeException AssumePeriod

Constructors

this
this(short year, Month month, ubyte day)
this
this(Date date)
this
this(YearMonth yearMonth, AssumePeriod assumePeriod)
this
this(YearQuarter yearQuarter, AssumePeriod assumePeriodMonth, AssumePeriod assumePeriodDay)
this
this(Timestamp timestamp)
this
this(Timestamp timestamp)
this
this(const(char)[] str)
this
this(YearMonthDay ymd)
this
this(YearQuarter yq, AssumePeriod assumePeriodMonth, AssumePeriod assumePeriodDay)
this
this(YearQuarter yq, AssumePeriod assumePeriod)
this
this(YearMonth ym, AssumePeriod assumePeriod)
this
this(int _year, int _month, int _day)
this
deprecated this(int day)

Members

Aliases

date
deprecated alias date = Date

Returns the Date farthest in the future which is representable by Date.

opCast
alias opCast(T : Timestamp) = timestamp
opCast
alias opCast(T : YearQuarter) = yearQuarter
toString
alias toString = toISOExtString

Converts this Date to a string with the format YYYY-MM-DD. If writer is set, the resulting string will be written directly to it.

Classes

DateTimeException
class DateTimeException

Enums

AllowDayOverflow
enum AllowDayOverflow
AssumePeriod
enum AssumePeriod

Controls the assumed start period of days for YearMonth or days and quarters for YearQuarter

Month
enum Month
Quarter
enum Quarter

Functions

add
YearMonthDay add(long months, AllowDayOverflow allowOverflow)
add
YearMonthDay add(long quarters)
day
ubyte day()
dayNumber
int dayNumber()

Returns; Day Of Gregorian Calendar Minus One

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.

maxDay
ubyte maxDay(int year, int month)

The maximum valid Day in the given month in the given year.

month
Month month()
opBinary
int opBinary(Date rhs)
opBinary
Date opBinary(int rhs)
opBinary
Date opBinary(int rhs)
opBinaryRight
Date opBinaryRight(int rhs)
opCmp
int opCmp(Date rhs)

Compares this Date with the given Date.

opOpAssign
Date opOpAssign(int rhs)
quarter
Quarter quarter()
quarter
Quarter quarter(Month month)

Returns the quarter for a given month.

quarter
Quarter quarter()
timestamp
Timestamp timestamp()
timestamp
Timestamp timestamp()
toHash
uint toHash()
toISOExtString
string toISOExtString()
void toISOExtString(W w)

Converts this Date to a string with the format YYYY-MM-DD. If writer is set, the resulting string will be written directly to it.

toISOString
string toISOString()
void toISOString(W w)

Converts this Date to a string with the format YYYYMMDD. If writer is set, the resulting string will be written directly to it.

toSimpleString
string toSimpleString()
void toSimpleString(W w)

Converts this Date to a string with the format YYYY-Mon-DD. If writer is set, the resulting string will be written directly to it.

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.

year
short year()
yearIsLeapYear
bool yearIsLeapYear(int year)

Whether the given Gregorian Year is a leap year.

yearMonthDay
YearMonthDay yearMonthDay()
yearQuarter
YearQuarter yearQuarter()
yearQuarter
YearQuarter yearQuarter()

Properties

dayOfGregorianCal
int dayOfGregorianCal [@property getter]

The Xth day of the Gregorian Calendar that this Date is on.

dayOfGregorianCal
void dayOfGregorianCal [@property getter]

The Xth day of the Gregorian Calendar that this Date is on.

dayOfWeek
DayOfWeek dayOfWeek [@property getter]

Day of the week this Date is on.

dayOfYear
int dayOfYear [@property getter]

Day of the year this Date is on.

daysInMonth
ubyte daysInMonth [@property getter]

The last day in the month that this Date is in.

endOfMonth
Date endOfMonth [@property getter]

Date for the last day in the month that this Date is in.

endOfQuarter
Date endOfQuarter [@property getter]

Date for the last day in the quarter that this Date is in.

isAD
bool isAD [@property getter]

Whether the current year is a date in A.D.

isLeapYear
bool isLeapYear [@property getter]

Whether this Date is in a leap year.

julianDay
int julianDay [@property getter]

The Julian day for this Date at noon (since the Julian day changes at noon).

max
Date max [@property getter]

Returns the Date farthest in the future which is representable by Date.

min
Date min [@property getter]

Returns the Date farthest in the past which is representable by Date.

modJulianDay
long modJulianDay [@property getter]

The modified Julian day for any time on this date (since, the modified Julian day changes at midnight).

Static functions

fromDayNumber
Date fromDayNumber(int dayNumber)
fromISOExtString
bool fromISOExtString(const(C)[] str, Date value)
Date fromISOExtString(const(C)[] str)

Creates a Date from a string with the format YYYY-MM-DD.

fromISOString
bool fromISOString(const(C)[] str, Date value)
Date fromISOString(const(C)[] str)

Creates a Date from a string with the format YYYYMMDD.

fromSimpleString
bool fromSimpleString(const(C)[] str, Date value)
Date fromSimpleString(const(C)[] str)

Creates a Date from a string with the format YYYY-Mon-DD.

fromString
bool fromString(const(C)[] str, Date value)
Date fromString(const(C)[] str)

Creates a Date from a string with the format YYYY-MM-DD, YYYYMMDD, or YYYY-Mon-DD.

fromYMD
bool fromYMD(int _year, int _month, int _day, Date value)
trustedCreate
Date trustedCreate(int _year, int _month, int _day)

Structs

YearMonth
struct YearMonth

Represents a date as a pair of years and months.

YearQuarter
struct YearQuarter

Represents a date as a pair of years and quarters.

Variables

month
Month month;

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

Meta

Authors

Jonathan M Davis, Ilia Ki (boost-like and BetterC rework)