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) -> DateFormatterParameters
formatKNTimeFormat enum option. Required.
localeThe 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) -> DateFormatterParameters
formatString representing a valid date format. Required.
localeThe 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) -> StringParameters
fromDate object. Required.
formatKNTimeFormat enum value. Required.
localeThe 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) -> StringParameters
fromDate object. Required.
formatString representing a valid custom date format. Required.
localeThe 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.
View on GitHub
Install in Dash
KNDatesUtils Structure Reference