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
Int
Declaration
Swift
public var year: Int
-
Returns the month component of a Date as
Int
Declaration
Swift
public var month: Int
-
Returns the weekday of a Date as
String
Declaration
Swift
public var weekday: String
-
Returns the month component of a Date as
String
Declaration
Swift
public var monthAsString: String
-
Returns the day component of a Date as
Int
Declaration
Swift
public var day: Int
-
Returns the hour component of a Date as
Int
Declaration
Swift
public var hour: Int
-
Returns the minute component of a Date as
Int
Declaration
Swift
public var minute: Int
-
Returns the second component of a Date as
Int
Declaration
Swift
public var second: Int
-
Returns how many
PieceOfKit.TimeUnit
have passed in between two datesParameter
Parameter withDate: theDate
to compare againstParameter
Parameter unitOfTime: the
TimeUnit
to use for comparisonReturns
the time interval as a
Double
Declaration
Swift
public func inBetween(withDate: Date, unitOfTime: TimeUnit) -> Double
Parameters
withDate
the
Date
to compare againstunitOfTime
the
TimeUnit
to 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
Date
Declaration
Swift
public func addMonths(_ months: Int) -> Date
Parameters
months
number 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
Date
Declaration
Swift
public func addDays(_ days: Int) -> Date
Parameters
days
number 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
Date
Declaration
Swift
public func addHours(_ hours: Int) -> Date
Parameters
hours
number 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
Date
Declaration
Swift
public func addMinutes(_ minutes: Int) -> Date
Parameters
minutes
number 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
Date
Declaration
Swift
public func addSeconds(_ seconds: Int) -> Date
Parameters
seconds
number of seconds as
Int
. Accepts negative numbers.Return Value
a
Date
-
Turns a Date into a String
Parameter
Parameter format: a
StringDateFormat
Returns
a
String
in the format yyyyMMdd, yyyyMMddHHmm or yyyyMMddHHmmssDeclaration
Swift
public func toString(stringDateFormat format: StringDateFormat = StringDateFormat.yyyyMMdd) -> String
Parameters
format
a
StringDateFormat
Return Value
a
String
in the format yyyyMMdd, yyyyMMddHHmm or yyyyMMddHHmmss
-
Turns a
String
into aDate
Parameter
Parameter format: the input format of the string. For example,
20161129
isStringDateFormat.YYYYMMDD
Returns
a
Date
Declaration
Swift
public static func fromString(_ string: String, stringDateFormat format: StringDateFormat = StringDateFormat.yyyyMMdd) -> Date?
Parameters
format
the input format of the string. For example, “20161129” is
StringDateFormat.YYYYMMDD
Return Value
a
Date