Skip to content

Commit a462ce3

Browse files
committed
Merge branch 'release/6.0.2'
2 parents 8da3c1c + aa7977b commit a462ce3

9 files changed

Lines changed: 37 additions & 28 deletions

File tree

Documentation/0.Informations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ $ brew install carthage
117117
To integrate SwiftDate into your Xcode project using Carthage, specify it in your `Cartfile`:
118118

119119
```ogdl
120-
github "malcommac/SwiftDate" ~> 5.0
120+
github "malcommac/SwiftDate" ~> 6.0
121121
```
122122

123123
Run `carthage update` to build the framework and drag the built `SwiftDate.framework` into your Xcode project.

Documentation/1.Introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ However this is a special region called **Default Region** and - by default - it
6565

6666
- **Time Zone** = GMT - this allows to keep a coerent behaviour with the default Date managment unless you change it.
6767
- **Calendar** = current's device calendar (auto updating)
68-
- **Locale** = current's device lcoale (auto updating)
68+
- **Locale** = current's device locale (auto updating)
6969

7070
While it's a good choice to always uses `DateInRegion` you can also work with `Date` by changing the default region as follow:
7171

Sources/SwiftDate/Formatters/Formatter+Protocols.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public protocol StringToDateTransformable {
2525
/// - rss: The RSS formatted date "EEE, d MMM yyyy HH:mm:ss ZZZ" i.e. "Fri, 09 Sep 2011 15:26:08 +0200"
2626
/// - altRSS: The Alternative RSS formatted date "d MMM yyyy HH:mm:ss ZZZ" i.e. "09 Sep 2011 15:26:08 +0200"
2727
/// - dotNet: The dotNet formatted date "/Date(%d%d)/" i.e. "/Date(1268123281843)/"
28-
/// - httpHeader: The http header formatted date "EEE, dd MM yyyy HH:mm:ss zzz" i.e. "Tue, 15 Nov 1994 12:45:26 GMT"
28+
/// - httpHeader: The http header formatted date "EEE, dd MMM yyyy HH:mm:ss zzz" i.e. "Tue, 15 Nov 1994 12:45:26 GMT"
2929
/// - custom: custom string format
3030
/// - standard: A generic standard format date i.e. "EEE MMM dd HH:mm:ss Z yyyy"
3131
/// - date: Date only format (short = "2/27/17", medium = "Feb 27, 2017", long = "February 27, 2017", full = "Monday, February 27, 2017"
@@ -88,7 +88,7 @@ public enum DateToStringStyles {
8888
/// - rss: The RSS formatted date "EEE, d MMM yyyy HH:mm:ss ZZZ" i.e. "Fri, 09 Sep 2011 15:26:08 +0200"
8989
/// - altRSS: The Alternative RSS formatted date "d MMM yyyy HH:mm:ss ZZZ" i.e. "09 Sep 2011 15:26:08 +0200"
9090
/// - dotNet: The dotNet formatted date "/Date(%d%d)/" i.e. "/Date(1268123281843)/"
91-
/// - httpHeader: The http header formatted date "EEE, dd MM yyyy HH:mm:ss zzz" i.e. "Tue, 15 Nov 1994 12:45:26 GMT"
91+
/// - httpHeader: The http header formatted date "EEE, dd MMM yyyy HH:mm:ss zzz" i.e. "Tue, 15 Nov 1994 12:45:26 GMT"
9292
/// - strict: custom string format with lenient options active
9393
/// - custom: custom string format
9494
/// - standard: A generic standard format date i.e. "EEE MMM dd HH:mm:ss Z yyyy"

Sources/SwiftDate/Formatters/ISOFormatter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class ISOFormatter: DateToStringTrasformable {
6868

6969
/// Evaluate formatting string
7070
public var dateFormat: String {
71-
if contains(.withInternetDateTimeExtended) {
71+
if contains(.withInternetDateTimeExtended) || contains(.withoutTZSeparators) {
7272
if contains(.withoutTZSeparators) {
7373
return "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"
7474
}

Sources/SwiftDate/Formatters/RelativeFormatter/RelativeFormatter+Style.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
import Foundation
1010

11+
#if os(Linux)
12+
import Glibc
13+
#else
14+
import Darwin
15+
#endif
16+
1117
/// Languages table.
1218
/// In order to be fully compatible with Linux environment we need to
1319
/// handle directly with .swift files instead of plain text files.
@@ -151,10 +157,10 @@ public extension RelativeFormatter {
151157
case flooring
152158
case custom((Double) -> Double)
153159

154-
func round(_ value: Double) -> Double {
160+
func roundValue(_ value: Double) -> Double {
155161

156162
switch self {
157-
case .regularRound: return Darwin.round(value)
163+
case .regularRound: return round(value)
158164
case .ceiling: return ceil(value)
159165
case .flooring: return floor(value)
160166
case .custom(let roundingFunction): return roundingFunction(value)

Sources/SwiftDate/Formatters/RelativeFormatter/RelativeFormatter.swift

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,25 @@ public class RelativeFormatter: DateToStringTrasformable {
162162
///
163163
/// - Parameter locale: locale to load
164164
/// - Returns: language table
165-
private func language(forLocale locale: Locale) -> RelativeFormatterLang {
166-
let localeId = (locale.collatorIdentifier ?? Locales.english.toLocale().collatorIdentifier!)
167-
guard let table = languagesCache[localeId] else {
168-
var tableType = languagesMap[localeId]
169-
if tableType == nil {
170-
tableType = languagesMap[localeId.components(separatedBy: "-").first!]
171-
if tableType == nil {
172-
return language(forLocale: Locales.english.toLocale())
173-
}
174-
}
175-
let instanceOfTable = tableType!.init()
176-
languagesCache[localeId] = instanceOfTable
177-
return instanceOfTable
178-
}
179-
return table
180-
}
165+
private func language(forLocale locale: Locale) -> RelativeFormatterLang {
166+
let localeId = (locale.collatorIdentifier ?? Locales.english.toLocale().collatorIdentifier!)
167+
guard let table = languagesCache[localeId] else {
168+
var tableType = languagesMap[localeId]
169+
if tableType == nil {
170+
tableType = languagesMap[localeId.components(separatedBy: "_").first!]
171+
if tableType == nil {
172+
tableType = languagesMap[localeId.components(separatedBy: "-").first!]
173+
}
174+
if tableType == nil {
175+
return language(forLocale: Locales.english.toLocale())
176+
}
177+
}
178+
let instanceOfTable = tableType!.init()
179+
languagesCache[localeId] = instanceOfTable
180+
return instanceOfTable
181+
}
182+
return table
183+
}
181184

182185
/// Implementation of the protocol for DateToStringTransformable.
183186
public static func format(_ date: DateRepresentable, options: Any?) -> String {
@@ -238,7 +241,7 @@ public class RelativeFormatter: DateToStringTrasformable {
238241
amount = round(amount / granularity) * granularity
239242
}
240243

241-
let value: Double = -1.0 * Double(elapsed.sign) * suitableRule.roundingStrategy.round(amount)
244+
let value: Double = -1.0 * Double(elapsed.sign) * suitableRule.roundingStrategy.roundValue(amount)
242245
let formatString = relativeFormat(locale: locale, flavour: flavour, value: value, unit: suitableRule.unit)
243246
return formatString.replacingOccurrences(of: "{0}", with: String(Int(abs(value))))
244247
}

Sources/SwiftDate/Foundation+Extras/TimeInterval+Formatter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public extension TimeInterval {
5555
formatter.calendar = calendar
5656
}
5757

58-
init() {}
58+
public init() {}
5959
}
6060

6161
/// Return the local thread shared formatter for date components

Sources/SwiftDate/Supports/Commons.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ public struct DateFormats {
128128
/// The RSS formatted date "EEE, d MMM yyyy HH:mm:ss ZZZ" i.e. "Fri, 09 Sep 2011 15:26:08 +0200"
129129
public static let rss: String = "EEE, d MMM yyyy HH:mm:ss ZZZ"
130130

131-
/// The http header formatted date "EEE, dd MM yyyy HH:mm:ss zzz" i.e. "Tue, 15 Nov 1994 12:45:26 GMT"
132-
public static let httpHeader: String = "EEE, dd MM yyyy HH:mm:ss zzz"
131+
/// The http header formatted date "EEE, dd MMM yyyy HH:mm:ss zzz" i.e. "Tue, 15 Nov 1994 12:45:26 GMT"
132+
public static let httpHeader: String = "EEE, dd MMM yyyy HH:mm:ss zzz"
133133

134134
/// A generic standard format date i.e. "EEE MMM dd HH:mm:ss Z yyyy"
135135
public static let standard: String = "EEE MMM dd HH:mm:ss Z yyyy"

SwiftDate.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "SwiftDate"
3-
s.version = "6.0.1"
3+
s.version = "6.0.2"
44
s.summary = "The best way to deal with Dates & Time Zones in Swift"
55
s.homepage = "https://github.com/malcommac/SwiftDate.git"
66
s.license = { :type => "MIT", :file => "LICENSE" }

0 commit comments

Comments
 (0)