pusher / chatkit-swift

Swift SDK for Pusher Chatkit
https://pusher.com/chatkit
MIT License
40 stars 16 forks source link

Message Created/Updated Date #60

Closed nitrag closed 6 years ago

nitrag commented 6 years ago

Is there a particular reason why the createdAt and updatedAt timestamps are strings?

https://github.com/pusher/chatkit-swift/blob/b81a9b04a043c52b2d5e85b06c51b2874a462fcd/Sources/PCMessage.swift#L6

If there is cause to keep them as string, can you at least add this function to easily grab Date when needed?

    public var createdDate: Date {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
        return dateFormatter.date(from: self.createdAt) ?? Date()
    }
hamchapman commented 6 years ago

This has been added as of 0.5.0: e.g. https://github.com/pusher/chatkit-swift/blob/f4182fcf404fd0a27ad3d96fc1acdfea010f535a/Sources/PCMessage.swift#L18