Improved the overall documentation for the public and internal types in the package.
This commit is contained in:
@@ -31,10 +31,16 @@ extension ISOTimestampTranscoder: DateTranscoder {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
/// Encodes a date into an ISO timestamp string.
|
||||
/// - Parameter date: A date to encode.
|
||||
/// - Returns: A string representation of the date in `yyyy-MM-dd'T'HH:mm:ss.SSSSSS` format.
|
||||
func encode(_ date: Date) throws -> String {
|
||||
dateFormatter.string(from: date)
|
||||
}
|
||||
|
||||
/// Decodes an ISO timestamp string into a date.
|
||||
/// - Parameter string: A string to decode.
|
||||
/// - Returns: A date parsed from the string, or the Unix epoch if the string cannot be parsed.
|
||||
func decode(_ string: String) throws -> Date {
|
||||
dateFormatter.date(from: string) ?? .init()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user