AWSDate

@interface AWSDate : NSObject

A flexible date/time formatting & parsing class.

It support the date formats used by Amazon, as well as common HTTP date formats.

  • Common HTTP date format. Example: Sun, 06 Nov 1994 08:49:37 GMT

    Declaration

    Objective-C

    + (nonnull NSString *)RFC1123TimestampFromDate:(nonnull NSDate *)date;

    Swift

    class func rfc1123Timestamp(from date: Date) -> String
  • Older date format. Example: Sun, 06-Nov-94 08:49:37 GMT

    Declaration

    Objective-C

    + (nonnull NSString *)RFC1036TimestampFromDate:(nonnull NSDate *)date;

    Swift

    class func rfc1036Timestamp(from date: Date) -> String
  • Really old date format. (format for C asctime() date string) Example: Sun Nov 6 08:49:37 1994

    Declaration

    Objective-C

    + (nonnull NSString *)asctimeTimestampFromDate:(nonnull NSDate *)date;

    Swift

    class func asctimeTimestamp(from date: Date) -> String
  • Standard Internet date format. Example: 2016-07-11T21:05:46Z

    Declaration

    Objective-C

    + (nonnull NSString *)ISO8601TimestampFromDate:(nonnull NSDate *)date;

    Swift

    class func iso8601Timestamp(from date: Date) -> String
  • Short date format used by Amazon (during request signing). Example: 20160711

    Declaration

    Objective-C

    + (nonnull NSString *)shortTimestampFromDate:(nonnull NSDate *)date;

    Swift

    class func shortTimestamp(from date: Date) -> String
  • Attempts to parse a date string assumed to be in RFC 1123 format. If you’re unsure of the exact date format, you can use -parseTimestamp: instead.

    Declaration

    Objective-C

    + (nullable NSDate *)parseRFC1123Timestamp:(nonnull NSString *)dateTimeStr;

    Swift

    class func parseRFC1123Timestamp(_ dateTimeStr: String) -> Date?
  • Attempts to parse a date string assumed to be in RFC 1036 format. If you’re unsure of the exact date format, you can use -parseTimestamp: instead.

    Declaration

    Objective-C

    + (nullable NSDate *)parseRFC1036Timestamp:(nonnull NSString *)dateTimeStr;

    Swift

    class func parseRFC1036Timestamp(_ dateTimeStr: String) -> Date?
  • Attempts to parse a date string assumed to be in asctime format. If you’re unsure of the exact date format, you can use -parseTimestamp: instead.

    Declaration

    Objective-C

    + (nullable NSDate *)parseAsctimeTimestamp:(nonnull NSString *)dateTimeStr;

    Swift

    class func parseAsctimeTimestamp(_ dateTimeStr: String) -> Date?
  • Attempts to parse a date string assumed to be in SO 8601 format. If you’re unsure of the exact date format, you can use -parseTimestamp: instead.

    Declaration

    Objective-C

    + (nullable NSDate *)parseISO8601Timestamp:(nonnull NSString *)dateTimeStr;

    Swift

    class func parseISO8601Timestamp(_ dateTimeStr: String) -> Date?
  • Will parse a date in any of the following formats:

    • RFC 1123
    • RFC 1036
    • asctime
    • ISO 8601

    This is the smart parsing method that generally just works.

    Declaration

    Objective-C

    + (nullable NSDate *)parseTimestamp:(nonnull NSString *)dateTimeStr;

    Swift

    class func parseTimestamp(_ dateTimeStr: String) -> Date?