TimeFormat.swift 516 B

12345678910111213141516171819202122
  1. //
  2. // TimeFormat.swift
  3. // RileyLink
  4. //
  5. // Created by Pete Schwamb on 3/8/16.
  6. // Copyright © 2016 Pete Schwamb. All rights reserved.
  7. //
  8. import Foundation
  9. class TimeFormat: NSObject {
  10. private static var formatterISO8601 = DateFormatter.ISO8601DateFormatter()
  11. static func timestampStrFromDate(_ date: Date) -> String {
  12. return formatterISO8601.string(from: date)
  13. }
  14. static func dateFromTimestamp(_ string: String) -> Date? {
  15. return formatterISO8601.date(from: string)
  16. }
  17. }