GPKGDateConverter

Objective-C

@interface GPKGDateConverter : NSObject

Swift

class GPKGDateConverter : NSObject

Date converter between database date formats and date objects

  • Is parsing a date value from a string always expected

    Declaration

    Objective-C

    @property (nonatomic) BOOL expected;

    Swift

    var expected: Bool { get set }
  • Get a default date converter for all property configured date and date time formats

    Declaration

    Objective-C

    + (GPKGDateConverter *)converter;

    Return Value

    date converter

  • Get a date converter for the data type

    Declaration

    Objective-C

    + (GPKGDateConverter *)converter:(enum GPKGDataType)type;

    Swift

    /*not inherited*/ init!(_ type: GPKGDataType)

    Parameters

    type

    data type

    Return Value

    date converter

  • Get a date converter

    Declaration

    Objective-C

    + (GPKGDateConverter *)dateConverter;

    Return Value

    date converter

  • Get a date time converter

    Declaration

    Objective-C

    + (GPKGDateConverter *)dateTimeConverter;

    Swift

    class func dateTime() -> GPKGDateConverter!

    Return Value

    date converter

  • Get a date converter for the provided format

    Declaration

    Objective-C

    + (GPKGDateConverter *)createWithFormat:(NSString *)format;

    Swift

    class func create(withFormat format: String!) -> GPKGDateConverter!

    Parameters

    format

    format

    Return Value

    date converter

  • Get a date converter for the provided formats

    Declaration

    Objective-C

    + (GPKGDateConverter *)createWithFormats:(NSArray<NSString *> *)formats;

    Swift

    class func create(withFormats formats: [String]!) -> GPKGDateConverter!

    Parameters

    formats

    formats

    Return Value

    date converter

  • Initialize

    Declaration

    Objective-C

    - (instancetype)initWithFormat:(NSString *)format;

    Swift

    init!(format: String!)

    Parameters

    format

    date format

  • Initialize

    Declaration

    Objective-C

    - (instancetype)initWithFormats:(NSArray<NSString *> *)formats;

    Swift

    init!(formats: [String]!)

    Parameters

    formats

    date formats

  • Add date format

    Declaration

    Objective-C

    - (void)addFormat:(NSString *)format;

    Swift

    func addFormat(_ format: String!)

    Parameters

    format

    date format

  • Get the formatted string date value of the date

    Declaration

    Objective-C

    - (NSString *)stringValue:(NSDate *)date;

    Swift

    func stringValue(_ date: Date!) -> String!

    Parameters

    date

    date

    Return Value

    formatted string date

  • Get the date value of the formatted string date

    Declaration

    Objective-C

    - (NSDate *)dateValue:(NSString *)date;

    Swift

    func dateValue(_ date: String!) -> Date!

    Parameters

    date

    formatted string date

    Return Value

    date

  • Convert a datetime string to a date

    Declaration

    Objective-C

    + (NSDate *)convertToDateWithString:(NSString *)dateTimeString;

    Swift

    class func convertToDate(with dateTimeString: String!) -> Date!

    Parameters

    dateTimeString

    datetime string

    Return Value

    date, or nil if the dateTimeString is nil or empty

  • Convert a datetime string to a date

    Declaration

    Objective-C

    + (NSDate *)convertToDateWithString:(NSString *)dateTimeString
                            andExpected:(BOOL)expected;

    Swift

    class func convertToDate(with dateTimeString: String!, andExpected expected: Bool) -> Date!

    Parameters

    dateTimeString

    datetime string

    expected

    if a parsed date is expected

    Return Value

    date, or nil if the dateTimeString is nil or empty

  • Convert a date to the provided string format

    Declaration

    Objective-C

    + (NSString *)convertToStringWithDate:(NSDate *)date
                               withFormat:(NSString *)format;

    Swift

    class func convertToString(with date: Date!, withFormat format: String!) -> String!

    Parameters

    date

    date

    format

    date format

    Return Value

    string formatted date

  • Convert a date to the string format: yyyy-MM-dd

    Declaration

    Objective-C

    + (NSString *)convertToDateStringWithDate:(NSDate *)date;

    Swift

    class func convertToDateString(with date: Date!) -> String!

    Parameters

    date

    date

    Return Value

    string formatted date

  • Convert a date to the string format: yyyy-MM-dd’T'HH:mm:ss.SSS'Z’

    Declaration

    Objective-C

    + (NSString *)convertToDateTimeStringWithDate:(NSDate *)date;

    Swift

    class func convertToDateTimeString(with date: Date!) -> String!

    Parameters

    date

    date

    Return Value

    string formatted date

  • Convert a date to the corresponding data type string format

    Declaration

    Objective-C

    + (NSString *)convertToStringWithDate:(NSDate *)date
                                  andType:(enum GPKGDataType)dataType;

    Swift

    class func convertToString(with date: Date!, andType dataType: GPKGDataType) -> String!

    Parameters

    date

    date

    dataType

    date data type

    Return Value

    string formatted date

  • Create a date formatter with the provided format

    Declaration

    Objective-C

    + (NSDateFormatter *)createFormatterWithFormat:(NSString *)format;

    Swift

    class func createFormatter(withFormat format: String!) -> DateFormatter!

    Parameters

    format

    date format

    Return Value

    date formatter

  • Determine if the date/time string value is a SQLite function

    Declaration

    Objective-C

    + (BOOL)isFunction:(NSString *)value;

    Swift

    class func isFunction(_ value: String!) -> Bool

    Parameters

    value

    date/time string value

    Return Value

    true if a function, false if the value should be parsed