Date
extension Date
-
Constant time stamp format
Declaration
Swift
public static let CheetahDateFormat: String
-
Constant date format
Declaration
Swift
public static let CheetahStringFormat: String
-
Static method that creates a
Date
object from a string with a given formatDeclaration
Swift
public static func dateFrom(string: String, withFormat format: String) -> Date?
Parameters
string
The formatted date string
format
The format of the string-represented date
Return Value
The created
Date
object -
Static method that creates a
Date
object from a time stamp stringDeclaration
Swift
public static func dateFrom(timestampString timestamp: String) -> Date?
Parameters
timestamp
The time stamp string
Return Value
The created
Date
object -
Static method that creates a
Date
object from a formatted string with theDate.CheetahStringFormat
formatDeclaration
Swift
public static func dateFrom(formattedString string: String) -> Date?
Parameters
string
The formatted date string
Return Value
The created
Date
object -
Instance method that creates a formatted dates string using the default locale (en_US_POSIX) and a specified format
Declaration
Swift
public func string(withFormat format: String, locale: Locale? = nil) -> String
Parameters
format
The desired format
locale
The locale that will be used
-
Instance method that creates the time stamp string from
Date
object using theDate.CheetahDateFormat
formatDeclaration
Swift
public var timestampString: String { get }
-
Instance method that creates a formatted date string from the current locale using a specified format
Declaration
Swift
public func localizedString(withFormat format: String) -> String
Parameters
format
The desired format
Return Value
The formatted date string
-
Instance method that creates a formatted string of the date using the specified format
Declaration
Swift
public func formattedStringWithDate(showDate: Bool, showTime: Bool, timeZone: TimeZone = .current) -> String?
Parameters
showDate
Show date with long format
showTime
Show time with short format
timeZone
Time zone that will be used
Return Value
The formatted date string
-
Instance method that calculates the number of years between a given date
Declaration
Swift
public func numberOfYears(fromDate date: Date) -> Int?
Parameters
date
TThe given date to calculate against
Return Value
The number of years between the given date