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.
							
						Struct std.datetime.date.DateTime
Combines the Date and
    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
    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.
						
				struct DateTime
				;
						
					
				Constructors
| Name | Description | 
|---|---|
| this | |
| this | 
Properties
| Name | Type | Description | 
|---|---|---|
| date[get] | Date | The date portion of DateTime. | 
| date[set] | const(Date) | The date portion of DateTime. | 
| day[get] | ubyte | Day of a Gregorian Month. | 
| day[set] | int | Day of a Gregorian Month. | 
| dayOfGregorianCal[get] | int | The Xth day of the Gregorian Calendar that this DateTimeis on. | 
| dayOfGregorianCal[set] | int | The Xth day of the Gregorian Calendar that this DateTimeis on.
        Setting this property does not affect the time portion ofDateTime. | 
| dayOfWeek[get] | DayOfWeek | Day of the week this DateTimeis on. | 
| dayOfYear[get] | ushort | Day of the year this DateTimeis on. | 
| dayOfYear[set] | int | Day of the year. | 
| daysInMonth[get] | ubyte | The last day in the month that this DateTimeis in. | 
| endOfMonth[get] | DateTime | DateTimefor the last day in the month that thisDateTimeis in. The time portion of endOfMonth is always
        23:59:59. | 
| hour[get] | ubyte | Hours past midnight. | 
| hour[set] | int | Hours past midnight. | 
| isAD[get] | bool | Whether the current year is a date in A.D. | 
| isLeapYear[get] | bool | Whether this DateTimeis in a leap year. | 
| isoWeek[get] | ubyte | The ISO 8601 week of the year that this DateTimeis in. | 
| julianDay[get] | long | The Julian day for this DateTimeat 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. | 
| max[get] | DateTime | Returns the DateTimefarthest in the future which is
        representable byDateTime. | 
| min[get] | DateTime | Returns the DateTimefarthest in the past which is representable
        byDateTime. | 
| minute[get] | ubyte | Minutes past the hour. | 
| minute[set] | int | Minutes past the hour. | 
| modJulianDay[get] | long | The modified Julian day for any time on this date (since, the modified Julian day changes at midnight). | 
| month[get] | Month | Month of a Gregorian Year. | 
| month[set] | Month | Month of a Gregorian Year. | 
| second[get] | ubyte | Seconds past the minute. | 
| second[set] | int | Seconds past the minute. | 
| timeOfDay[get] | TimeOfDay | The time portion of DateTime. | 
| timeOfDay[set] | const(TimeOfDay) | The time portion of DateTime. | 
| year[get] | short | Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive are B.C. | 
| year[set] | int | Year of the Gregorian Calendar. Positive numbers are A.D. Non-positive are B.C. | 
| yearBC[get] | short | Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C. | 
| yearBC[set] | int | Year B.C. of the Gregorian Calendar counting year 0 as 1 B.C. | 
Methods
| Name | Description | 
|---|---|
| add | Adds the given number of years or months to this DateTime. A
        negative number will subtract. | 
| diffMonths | Returns the difference between the two DateTimes in months. | 
| fromISOExtString | Creates a DateTimefrom a string with the format
        YYYY-MM-DDTHH:MM:SS. Whitespace is stripped from the given string. | 
| fromISOString | Creates a DateTimefrom a string with the format YYYYMMDDTHHMMSS.
        Whitespace is stripped from the given string. | 
| fromSimpleString | Creates a DateTimefrom a string with the format
        YYYY-Mon-DD HH:MM:SS. Whitespace is stripped from the given string. | 
| opBinary | Gives the result of adding or subtracting a Durationfrom thisDateTime. | 
| opBinary | Gives the difference between two DateTimes. | 
| opCmp | Compares this DateTimewith the givenDateTime. | 
| opOpAssign | Gives the result of adding or subtracting a duration from this DateTime, as well as assigning the result to thisDateTime. | 
| roll | Adds the given number of years or months to this DateTime. A
        negative number will subtract. | 
| roll | Adds the given number of units to this DateTime. A negative
        number will subtract. | 
| toISOExtString | Converts this DateTimeto a string with the formatYYYY-MM-DDTHH:MM:SS. Ifwriteris set, the resulting
        string will be written directly to it. | 
| toISOString | Converts this DateTimeto a string with the formatYYYYMMDDTHHMMSS.
        Ifwriteris set, the resulting string will be written directly to it. | 
| toSimpleString | Converts this DateTimeto a string with the formatYYYY-Mon-DD HH:MM:SS. Ifwriteris set, the resulting
        string will be written directly to it. | 
| toString | Converts this DateTimeto a string. | 
Example
import coreAuthors
License
					Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.