mir.date

Fast BetterC Date type with Boost ABI and mangling compatability.

CategoryFunctions
Main date typesDate
Other date typesMonth DayOfWeek
Date checkingvalid yearIsLeapYear
Date conversiondaysToDayOfWeek
OtherAllowDayOverflow DateTimeException

Constructors

this
this(short year, Month month, ubyte day)
this
this(Date date)
this
this(Timestamp timestamp)
this
this(Timestamp timestamp)
this
this(const(char)[] str)
this
this(YearMonthDay ymd)
this
this(int _year, int _month, int _day)
this
this(int day)

Members

Aliases

Date
alias Date = date

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

opCast
alias opCast(T : Timestamp) = timestamp
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
Month
enum Month

Functions

_addDays
Date _addDays(long days)
Undocumented in source. Be warned that the author may not have intended to support it.
add
YearMonthDay add(long months, AllowDayOverflow allowOverflow)
Undocumented in source. Be warned that the author may not have intended to support it.
add
YearMonthDay add(long years, AllowDayOverflow allowOverflow)
Undocumented in source. Be warned that the author may not have intended to support it.
add
Date add(long amount, AllowDayOverflow allowOverflow)
Undocumented in source. Be warned that the author may not have intended to support it.
day
ubyte day()
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.

getDayOfWeek
DayOfWeek getDayOfWeek(int day)
Undocumented in source. Be warned that the author may not have intended to support it.
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 lhs)
opBinary
Date opBinary(int lhs)
opBinary
Date opBinary(int lhs)
opBinaryRight
Date opBinaryRight(int lhs)
opCmp
int opCmp(Date rhs)

Compares this Date with the given Date.

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()
yearMonthDayImpl
YearMonthDay yearMonthDayImpl()
Undocumented in source. Be warned that the author may not have intended to support it.

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

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)

Static variables

_dict
auto _dict;
Undocumented in source.

Variables

_julianDay
int _julianDay;
Undocumented in source.
_monthNames
string[12] _monthNames;
Undocumented in source.
day
ubyte day;
Undocumented in source.
month
Month month;

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

Meta

License

Apache-2.0

Authors

Jonathan M Davis, Ilya Yaroshenko (boost-like and BetterC rework)