Date

public extension Date

Date+Editable provides additional edit function for a date object.

Author

Adamas

Version

1.9.5

Date

11/05/2023
  • Adding certain days to the current date

    Declaration

    Swift

    func adding(days: Int = 0,
                hours: Int = 0,
                mins: Int = 0,
                secs: Int = 0) -> Date

    Parameters

    days

    Days to be added. Default to 0.

    hours

    Hours to be added. Default to 0.

    mins

    Hours to be added. Default to 0.

    secs

    Hours to be added. Default to 0.

    Return Value

    The new date object

  • Common patterns.

    Declaration

    Swift

    static let fullYearPattern: String
  • Undocumented

    Declaration

    Swift

    static let yearPattern: String
  • Undocumented

    Declaration

    Swift

    static let abbrMonthPattern: String
  • Undocumented

    Declaration

    Swift

    static let monthPattern: String
  • Undocumented

    Declaration

    Swift

    static let dayPattern: String
  • Undocumented

    Declaration

    Swift

    static let time12HourPattern: String
  • Default date formatter

    Declaration

    Swift

    static let defaultDateFormatter: DateFormatter
  • The object that only contains the date information of the origin object

    Declaration

    Swift

    var date: Date { get }
  • Convert the time gap between the time specified and the current time to a simple time offset string. Such as “3 Hrs Ago”.

    Declaration

    Swift

    func timeOffsetString(withPrecision precision: Int = Int.max,
                          withAbbreviation shouldUseAbbreviation: Bool = false) -> String

    Parameters

    precision

    How many units should be included.

    shouldUseAbbreviation

    Whether the time description should be abbreviation or not.

    Return Value

    The time offset string.

  • Format the date with a given pattern

    Declaration

    Swift

    func string(withPattern pattern: String,
                dateFormatter: DateFormatter = Self.defaultDateFormatter) -> String

    Parameters

    pattern

    The pattern

    dateFormatter

    The formatter to be used

    Return Value

    The formatted string

    • dateFormatter: The formatter to be used

  • Format the date with a given format

    Declaration

    Swift

    func string(with dateFormat: DateFormatType,
                dateFormatter: DateFormatter = Self.defaultDateFormatter) -> String

    Parameters

    dateFormat

    The format

    dateFormatter

    The formatter to be used

    Return Value

    The formatted string

  • Initialize a date with a given string and a pattern

    Declaration

    Swift

    init?(string: String,
          pattern: String,
          dateFormatter: DateFormatter = Self.defaultDateFormatter)

    Parameters

    string

    The string

    pattern

    The pattern

    dateFormatter

    The formatter to be used

  • Initialize a date with a given string and a pattern

    Declaration

    Swift

    init?(string: String,
          dateFormat: DateFormatType,
          dateFormatter: DateFormatter = Self.defaultDateFormatter)

    Parameters

    string

    The string

    dateFormat

    The format

    dateFormatter

    The formatter to be used