KNDatesUtils
public struct KNDatesUtils
Helper struct which returns date formatters or formatted strings by using the formet formatter.
The format can be either a valid date format string or a KNTimeFormat
enum value.
Version
1.2.3-
Helper method to return a DateFormatter object to be used in formatted
Version
1.2.3
Declaration
Swift
public static func formatter(with format: KNFormat, locale: Locale = Locale.current) -> DateFormatter
Parameters
format
KNTimeFormat enum option. Required.
locale
The locale to use for formatting when localising content
Return Value
A DateFormatter object using the date format passed.
-
Helper method to return a DateFormatter object to be used in formatted
Version
1.2.3
Declaration
Swift
public static func formatter(with format: String, locale: Locale = Locale.current) -> DateFormatter
Parameters
format
String representing a valid date format. Required.
locale
The locale to use for formatting when localising content
Return Value
A DateFormatter object using the date format passed.
-
Helper method that returns a formatted date as a string, accepting a KNTimeFormat value.
Version
1.2.3
Declaration
Swift
public static func string(from date: Date, format: KNFormat, locale: Locale = Locale.current) -> String
Parameters
from
Date object. Required.
format
KNTimeFormat enum value. Required.
locale
The locale to use for formatting when localising content
Return Value
A string representing the formatted date based on the KNTimeFormat and date passed in.
-
Helper method that returns a formatted date as a string, aceppting a custom date format as a string. E.g. “YYYY-MM-DD”
Version
1.2.3
Declaration
Swift
public static func string(from date: Date, format: String, locale: Locale = Locale.current) -> String
Parameters
from
Date object. Required.
format
String representing a valid custom date format. Required.
locale
The locale to use for formatting when localising content
Return Value
A string representing the formatted date based on the custom date format and date passed in.