Adds the given number of years or months to this DateTime, mutating it. A negative number will subtract.
Returns the difference between the two DateTimes in months.
Gives the result of adding or subtracting a core.time.Duration from this DateTime.
Gives the difference between two DateTimes.
Compares this DateTime with the given DateTime..
Adds the given number of years or months to this DateTime, mutating it. A negative number will subtract.
Adds the given number of units to this DateTime, mutating it. A negative number will subtract.
Converts this DateTime to a string with the format YYYY-MM-DDTHH:MM:SS. If writer is set, the resulting string will be written directly to it.
Converts this DateTime to a string with the format YYYYMMDDTHHMMSS. If writer is set, the resulting string will be written directly to it.
Converts this DateTime to a string with the format YYYY-Mon-DD HH:MM:SS. If writer is set, the resulting string will be written directly to it.
Converts this DateTime to a string.
The date portion of DateTime.
The date portion of DateTime.
Day of a Gregorian Month.
Day of a Gregorian Month.
The Xth day of the Gregorian Calendar that this DateTime is on.
Day of the week this DateTime is on.
Day of the year this DateTime is on.
Day of the year.
The last day in the month that this DateTime is in.
Hours past midnight.
Hours past midnight.
Whether the current year is a date in A.D.
Whether this DateTime is in a leap year.
The ISO 8601 week of the year that this DateTime is in.
The year of the ISO 8601 week calendar that this DateTime is in.
The Julian day for this DateTime at the given time. For example, prior to noon, 1996-03-31 would be the Julian day number 2_450_173, so this function returns 2_450_173, while from noon onward, the julian day number would be 2_450_174, so this function returns 2_450_174.
Minutes past the hour.
Minutes past the hour.
The modified Julian day for any time on this date (since, the modified Julian day changes at midnight).
Month of a Gregorian Year.
Month of a Gregorian Year.
Seconds past the minute.
Seconds past the minute.
The time portion of DateTime.
The time portion of DateTime.
Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive are B.C.
Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive are B.C.
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C.
Creates a DateTime from a string with the format YYYY-MM-DDTHH:MM:SS. Whitespace is stripped from the given string.
Creates a DateTime from a string with the format YYYYMMDDTHHMMSS. Whitespace is stripped from the given string.
Creates a DateTime from a string with the format YYYY-Mon-DD HH:MM:SS. Whitespace is stripped from the given string.
Represents a duration of time of weeks or less (kept internally as hnsecs). (e.g. 22 days or 700 seconds).
import core.time : days, seconds; auto dt = DateTime(2000, 6, 1, 10, 30, 0); assert(dt.date == Date(2000, 6, 1)); assert(dt.timeOfDay == TimeOfDay(10, 30, 0)); assert(dt.dayOfYear == 153); assert(dt.dayOfWeek == DayOfWeek.thu); dt += 10.days + 100.seconds; assert(dt == DateTime(2000, 6, 11, 10, 31, 40)); assert(dt.toISOExtString() == "2000-06-11T10:31:40"); assert(dt.toISOString() == "20000611T103140"); assert(dt.toSimpleString() == "2000-Jun-11 10:31:40"); assert(DateTime.fromISOExtString("2018-01-01T12:00:00") == DateTime(2018, 1, 1, 12, 0, 0)); assert(DateTime.fromISOString("20180101T120000") == DateTime(2018, 1, 1, 12, 0, 0)); assert(DateTime.fromSimpleString("2018-Jan-01 12:00:00") == DateTime(2018, 1, 1, 12, 0, 0));
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.