SwiftDate.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // SwiftDate
  3. // Parse, validate, manipulate, and display dates, time and timezones in Swift
  4. //
  5. // Created by Daniele Margutti
  6. // - Web: https://www.danielemargutti.com
  7. // - Twitter: https://twitter.com/danielemargutti
  8. // - Mail: hello@danielemargutti.com
  9. //
  10. // Copyright © 2019 Daniele Margutti. Licensed under MIT License.
  11. //
  12. import Foundation
  13. public struct SwiftDate {
  14. private init() { }
  15. /// The default region is used to manipulate and work with plain `Date` object and
  16. /// wherever a region parameter is optional. By default region is the to GMT timezone
  17. /// along with the default device's locale and calendar (both autoupdating).
  18. public static var defaultRegion = Region.UTC
  19. /// This is the ordered list of all formats SwiftDate can use in order to attempt parsing a passaed
  20. /// date expressed as string. Evaluation is made in order; you can add or remove new formats as you wish.
  21. /// In order to reset the list call `resetAutoFormats()` function.
  22. public static var autoFormats: [String] {
  23. set { DateFormats.autoFormats = newValue }
  24. get { return DateFormats.autoFormats }
  25. }
  26. /// Reset the list of all built-in auto formats patterns.
  27. public static func resetAutoFormats() {
  28. DateFormats.resetAutoFormats()
  29. }
  30. }