Skip to content

Commit

Permalink
Merge branch 'release/5.0.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
malcommac committed Oct 9, 2018
2 parents 8daeefa + d1611d3 commit 80e48d5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions Documentation/5.Date_Formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ takes one optional argument:
- `withInternetDateTime`: The format used for internet date times, according to the RFC 3339 standard. Equivalent to specifying `withFullDate`, `withFullTime`, `withDashSeparatorInDate`,
`withColonSeparatorInTime`, and `withColonSeparatorInTimeZone`.
- `withInternetDateTimeExtended`: The format used for internet date times; it's similar to `.withInternetDateTime` but include milliseconds (`yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ`).
- `withoutTZSeparators`: Print timezone of the date without time separator (`+0200` instead of `+02:00`). You can combine it with the following other options: `withInternetDateTimeExtended`, `withInternetDateTime` and when `withTimeZone == false && withTimeZone == true`

Examples:

Expand Down
13 changes: 13 additions & 0 deletions Sources/SwiftDate/Formatters/ISOFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,23 @@ public class ISOFormatter: DateToStringTrasformable {
// but include milliseconds ('yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ').
public static let withInternetDateTimeExtended = ISOFormatter.Options(rawValue: 1 << 11)

/// Print the timezone in format `ZZZ` instead of `ZZZZZ`
/// An example outout maybe be `+0200` instead of `+02:00`.
public static let withoutTZSeparators = ISOFormatter.Options(rawValue: 1 << 12)

/// Evaluate formatting string
public var dateFormat: String {
if self.contains(.withInternetDateTimeExtended) {
if self.contains(.withoutTZSeparators) {
return "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"
}
return "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
}

if self.contains(.withInternetDateTime) {
if self.contains(.withoutTZSeparators) {
return "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"
}
return "yyyy-MM-dd'T'HH:mm:ssZZZZZ"
}

Expand Down Expand Up @@ -141,6 +151,9 @@ public class ISOFormatter: DateToStringTrasformable {
format += "HH:mm:ss"
}
if self.contains(.withTimeZone) {
if self.contains(.withoutTZSeparators) {
return "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"
}
format += "ZZZZZ"
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDate/Supports/Commons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ internal func combineHashes(_ hashes: [Int]) -> Int {
private func combineHashValues(_ initial: Int, _ other: Int) -> Int {
#if arch(x86_64) || arch(arm64)
let magic: UInt = 0x9e3779b97f4a7c15
#elseif arch(i386) || arch(arm)
#elseif arch(i386) || arch(arm) || arch(arm64_32)
let magic: UInt = 0x9e3779b9
#endif
var lhs = UInt(bitPattern: initial)
Expand Down
2 changes: 1 addition & 1 deletion SwiftDate.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SwiftDate"
s.version = "5.0.9"
s.version = "5.0.10"
s.summary = "The best way to deal with Dates & Time Zones in Swift"
s.homepage = "https://github.com/malcommac/SwiftDate.git"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
2 changes: 1 addition & 1 deletion TestApplication/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down

0 comments on commit 80e48d5

Please sign in to comment.