Date
struct Date : ReferenceConvertible, Comparable, Equatable
-
Returns true if Date is today
Declaration
Swift
public var isToday: Bool -
Returns true if Date is yesterday
Declaration
Swift
public var isYesterday: Bool -
Returns true if Date is tomorrow
Declaration
Swift
public var isTomorrow: Bool -
Returns true if Date is within this month
Declaration
Swift
public var isThisMonth: Bool -
Returns true if Date is within this week
Declaration
Swift
public var isThisWeek: Bool -
Returns the year component of a Date as
IntDeclaration
Swift
public var year: Int -
Returns the month component of a Date as
IntDeclaration
Swift
public var month: Int -
Returns the weekday of a Date as
StringDeclaration
Swift
public var weekday: String -
Returns the month component of a Date as
StringDeclaration
Swift
public var monthAsString: String -
Returns the day component of a Date as
IntDeclaration
Swift
public var day: Int -
Returns the hour component of a Date as
IntDeclaration
Swift
public var hour: Int -
Returns the minute component of a Date as
IntDeclaration
Swift
public var minute: Int -
Returns the second component of a Date as
IntDeclaration
Swift
public var second: Int
-
Returns how many
PieceOfKit.TimeUnithave passed in between two datesParameter
Parameter withDate: theDateto compare againstParameter
Parameter unitOfTime: the
TimeUnitto use for comparisonReturns
the time interval as a
DoubleDeclaration
Swift
public func inBetween(withDate: Date, unitOfTime: TimeUnit) -> DoubleParameters
withDatethe
Dateto compare againstunitOfTimethe
TimeUnitto use for comparisonReturn Value
the time interval as a
Double -
Add months to a Date
Parameter
Parameter months: number of months as
Int. Accepts negative numbers.Returns
a
DateDeclaration
Swift
public func addMonths(_ months: Int) -> DateParameters
monthsnumber of months as
Int. Accepts negative numbers.Return Value
a
Date -
Add days to a Date
Parameter
Parameter days: number of days as
Int. Accepts negative numbers.Returns
a
DateDeclaration
Swift
public func addDays(_ days: Int) -> DateParameters
daysnumber of days as
Int. Accepts negative numbers.Return Value
a
Date -
Add hours to a Date
Parameter
Parameter hours: number of hours as
Int. Accepts negative numbers.Returns
a
DateDeclaration
Swift
public func addHours(_ hours: Int) -> DateParameters
hoursnumber of hours as
Int. Accepts negative numbers.Return Value
a
Date -
Add minutes to a Date
Parameter
Parameter minutes: number of minutes as
Int. Accepts negative numbers.Returns
a
DateDeclaration
Swift
public func addMinutes(_ minutes: Int) -> DateParameters
minutesnumber of minutes as
Int. Accepts negative numbers.Return Value
a
Date -
Add seconds to a Date
Parameter
Parameter seconds: number of seconds as
Int. Accepts negative numbers.Returns
a
DateDeclaration
Swift
public func addSeconds(_ seconds: Int) -> DateParameters
secondsnumber of seconds as
Int. Accepts negative numbers.Return Value
a
Date -
Turns a Date into a String
Parameter
Parameter format: a
StringDateFormatReturns
a
Stringin the format yyyyMMdd, yyyyMMddHHmm or yyyyMMddHHmmssDeclaration
Swift
public func toString(stringDateFormat format: StringDateFormat = StringDateFormat.yyyyMMdd) -> StringParameters
formata
StringDateFormatReturn Value
a
Stringin the format yyyyMMdd, yyyyMMddHHmm or yyyyMMddHHmmss
-
Turns a
Stringinto aDateParameter
Parameter format: the input format of the string. For example,
20161129
isStringDateFormat.YYYYMMDDReturns
a
DateDeclaration
Swift
public static func fromString(_ string: String, stringDateFormat format: StringDateFormat = StringDateFormat.yyyyMMdd) -> Date?Parameters
formatthe input format of the string. For example, “20161129” is
StringDateFormat.YYYYMMDDReturn Value
a
Date
Date Extension Reference