Date
struct Date : ReferenceConvertible, Comparable, Equatable
-
Alias to
Date#newreturns a new date with current date time.Declaration
Swift
static var now: Date -
Returns a new Date representing the date 1 day after today
Declaration
Swift
static var tommorow: Date -
Returns a new Date representing the date 1 day before today
Declaration
Swift
static var yesterday: Date -
Returns a date with timestamp, use
Date(timeIntervalSince1970:)initializer to create a new date.Declaration
Swift
static func at(_ timestamp: Int) -> DateParameters
timestampA unix timestamp
Return Value
A date
-
Returns a date with timestamp, use
Date(timeIntervalSince1970:)initializer to create a new date.Declaration
Swift
static func at(_ timestamp: Double) -> DateParameters
timestampA unix timestamp
Return Value
A date
-
Returns a new Date where one or more of the elements have been changed according to the passing parameter.
Declaration
Swift
func change(year: Int? = nil, month: Int? = nil, day: Int? = nil, hour: Int? = nil, minute: Int? = nil, second: Int? = nil) -> DateParameters
yearA int value
monthA int value
dayA int value
hourA int value
minuteA int value
secondA int value
Return Value
A new date
-
Returns and changes
selfwhere one or more of the elements have been changed according to the passing parameter.Declaration
Swift
mutating func changed(year: Int? = nil, month: Int? = nil, day: Int? = nil, hour: Int? = nil, minute: Int? = nil, second: Int? = nil) -> DateParameters
yearA int value
monthA int value
dayA int value
hourA int value
minuteA int value
secondA int value
Return Value
Self
-
Undocumented
See moreDeclaration
Swift
struct Date : ReferenceConvertible, Comparable, Equatable -
Adjusts receiver and returns an new date with corresponding time period.
Declaration
Swift
func at(_ period: Period) -> DateParameters
periodAn enum specify time period
Return Value
A new date
-
Converts Date with the time portion set to the beginning of the day (0:00)
Declaration
Swift
var beginningOfDay: Date -
Converts Date with the time portion set to the beginning of the day (0:00)
Declaration
Swift
var midnight: Date -
Converts Date with the time portion set to the middle of the day (12:00)
Declaration
Swift
var middleOfDay: Date -
Converts Date with the time portion set to the middle of the day (12:00)
Declaration
Swift
var midday: Date -
Converts Date with the time portion set to the middle of the day (12:00)
Declaration
Swift
var noon: Date -
Converts Date with the time portion set to the end of the day (23:59:59)
Declaration
Swift
var endOfDay: Date -
Returns a date object denoting the following day.
Declaration
Swift
var next: Date -
Returns a date object denoting the following day.
Declaration
Swift
var nextDay: Date -
Returns a date object denoting the following month.
Declaration
Swift
var nextMonth: Date -
Returns a date object denoting the following year.
Declaration
Swift
var nextYear: Date -
Returns a date object denoting the previous day.
Declaration
Swift
var prevDay: Date -
Returns a date object denoting the previous month.
Declaration
Swift
var prevMonth: Date -
Returns a date object denoting the previous year.
Declaration
Swift
var prevYear: Date -
Returns a date object pointing other days after self. The other should be a numeric value.
Declaration
Swift
func nextDay(_ n: Int = 1) -> DateParameters
nA integer value
Return Value
A new date
-
Returns a date object pointing n months after self. The argument n should be a numeric value.
Declaration
Swift
func nextMonth(_ n: Int = 1) -> DateParameters
nA integer value
Return Value
A new date
-
Returns a date object pointing n years after self. The argument n should be a numeric value.
Declaration
Swift
func nextYear(_ n: Int = 1) -> DateParameters
nA integer value
Return Value
A new date
-
Returns a date object pointing other days before self. The other should be a numeric value.
Declaration
Swift
func prevDay(_ n: Int = 1) -> DateParameters
nA integer value
Return Value
A new date
-
Returns a date object pointing n months before self. The argument n should be a numeric value.
Declaration
Swift
func prevMonth(_ n: Int = 1) -> DateParameters
nA integer value
Return Value
A new date
-
Returns a date object pointing n years before self. The argument n should be a numeric value.
Declaration
Swift
func prevYear(_ n: Int = 1) -> DateParameters
nA integer value
Return Value
A new date
-
Undocumented
Declaration
Swift
struct Date : ReferenceConvertible, Comparable, Equatable
-
Returns a date from given string or nil.
Date#parse(str:)can only parse string in several forms.See
See Also:DateFormat#parse(str:)Declaration
Swift
static func parse(str: String) -> Date?Parameters
strA string
Return Value
A date object or nil
-
Undocumented
Declaration
Swift
struct Date : ReferenceConvertible, Comparable, Equatable -
Undocumented
Declaration
Swift
struct Date : ReferenceConvertible, Comparable, Equatable -
Creates a
Dateinstance withtimespecstruct.Declaration
Swift
init(timespec: timespec)Parameters
timespecA timespec struct.
-
Returns true if the date is Sunday.
Declaration
Swift
var isSunday: Bool -
Returns true if the date is Monday.
Declaration
Swift
var isMonday: Bool -
Returns true if the date is Tuesday.
Declaration
Swift
var isTuesday: Bool -
Returns true if the date is Wednesday.
Declaration
Swift
var isWednesday: Bool -
Returns true if the date is Thursday.
Declaration
Swift
var isThursday: Bool -
Returns true if the date is Friday.
Declaration
Swift
var isFriday: Bool -
Returns true if the date is Saturday.
Declaration
Swift
var isSaturday: Bool -
Returns true if the date is leap year.
Declaration
Swift
var isLeapYear: Bool
-
Undocumented
Declaration
Swift
struct Date : ReferenceConvertible, Comparable, Equatable -
The number of era units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var era: Int -
The number of year units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var year: Int -
The number of month units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var month: Int -
The number of day units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var day: Int -
The number of hour units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var hour: Int -
The number of minute units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var minute: Int -
The number of second units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var second: Int -
The number of nanosecond units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var nanosecond: Int -
The number of weekday units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var weekday: Int -
The number of weekdayOrdinal units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var weekdayOrdinal: Int -
The number of quarter units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var quarter: Int -
The number of weekOfMonth units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var weekOfMonth: Int -
The number of weekOfYear units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var weekOfYear: Int -
The number of yearForWeekOfYear units for the receiver.
Note
This value is interpreted in the context of the calendar and timezone with which it is usedDeclaration
Swift
var yearForWeekOfYear: Int
-
Returns a new date with utc format.
Declaration
Swift
var to_utc: Date -
Returns a new date with utc format.
Declaration
Swift
var utc: Date
-
Converting the right hand side argument
DurationtoDateComponentsfirst and add it to the left hand sideDateobject.let date = Date(str: "2017-01-01 00:00:00 +0000")! date + 1.year #=> 2018-01-01 00:00:00 +0000 date + 2.years #=> 2019-01-01 00:00:00 +0000 date + 2.years + 1.month #=> 2019-02-01 00:00:00 +0000Declaration
Swift
static func +(lhs: Date, rhs: Duration) -> DateParameters
lhsA date
rhsA duration
Return Value
A new date which add the duration to the old date
-
Converting the right hand side argument
DurationtoDateComponentsfirst and minus it to the left hand sideDateobject.let date = Date(str: "2017-01-01 00:00:00 +0000")! date - 1.year #=> 2016-01-01 00:00:00 +0000 date - 2.years #=> 2015-01-01 00:00:00 +0000Declaration
Swift
static func -(lhs: Date, rhs: Duration) -> DateParameters
lhsA date
rhsA duration
Return Value
A new date which minus the duration to the old date
View on GitHub
Date Extension Reference