NSDateFormatter.swift 768 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // NSDateFormatter.swift
  3. // Naterade
  4. //
  5. // Created by Nathan Racklyeft on 11/25/15.
  6. // Copyright © 2015 Nathan Racklyeft. All rights reserved.
  7. //
  8. import Foundation
  9. // MARK: - Extensions useful in parsing fixture dates
  10. extension ISO8601DateFormatter {
  11. static func localTimeDate(timeZone: TimeZone = .currentFixed) -> Self {
  12. let formatter = self.init()
  13. formatter.formatOptions = .withInternetDateTime
  14. formatter.formatOptions.subtract(.withTimeZone)
  15. formatter.timeZone = timeZone
  16. return formatter
  17. }
  18. }
  19. extension DateFormatter {
  20. static var descriptionFormatter: DateFormatter {
  21. let formatter = self.init()
  22. formatter.dateFormat = "yyyy-MM-dd HH:mm:ssZZZZZ"
  23. return formatter
  24. }
  25. }