Skip to content

Commit

Permalink
Merge branch 'swift-4'
Browse files Browse the repository at this point in the history
  • Loading branch information
malcommac committed Sep 14, 2017
2 parents 9ff893f + 429498c commit d8670fa
Show file tree
Hide file tree
Showing 16 changed files with 919 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

## CHANGELOG

* Version **[4.3.0](#4300_4400)** (for Swift 3) and **[4.4.0](#4300_4400)**
* Version **[4.1.11](#4111)**
* Version **[4.1.10](#4110)**
* Version **[4.1.7](#417)**
Expand All @@ -28,6 +29,16 @@
* Version **[4.0.2](#402)**
* Version **[4.0.0](#400)**

<a name="4300_4400" />

## SwiftDate 4.3.0 (for Swift 3) and 4.4.0 (for Swift 4)
---
- **Release Date**: 2017-09-14
- **Zipped Version for Swift 3**: [Download 4.3.0](https://github.com/malcommac/SwiftDate/releases/tag/4.3.0)
- **Zipped Version for Swift 4**: [Download 4.4.0](https://github.com/malcommac/SwiftDate/releases/tag/4.4.0)

- [#480](https://github.com/malcommac/SwiftDate/pull/480) Fix for '-' operator both in `Date` and `DateInRegion` classes where the result is correctly reported.

<a name="4111" />

## SwiftDate 4.1.11
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Take a look here:

## Documentation
* **On [http://malcommac.github.io/SwiftDate/index.html](http://malcommac.github.io/SwiftDate/index.html) to learn more about all available functions with a comprehensive list of examples**
* The **latest [full class documentation is available here](http://cocoadocs.org/docsets/SwiftDate/4.1.11/)**
* The **latest [full class documentation is available here](http://cocoadocs.org/docsets/SwiftDate/4.4.0/)**

Code is documented for Xcode, so you can use the built-in documentation panel to learn more about the library.

Expand All @@ -59,7 +59,7 @@ You can also generate the latest documentation using [Jazzy](https://github.com/

## Current Release

- **Swift 4.x**: >= 4.4.0 [Download here](https://github.com/malcommac/SwiftDate/releases/tag/4.4.0).
- **Swift 4.x**: >= 4.4.0 - Latest is 4.4.0 [Download here](https://github.com/malcommac/SwiftDate/releases/tag/4.4.0).
- **Swift 3.x**: Latest compatible version is 4.3.0 [Download here](https://github.com/malcommac/SwiftDate/releases/tag/4.3.0)
- **Swift 2.3**: Latest compatible version is 3.0.9 on [swift_23 branch](https://github.com/malcommac/SwiftDate/tree/feature/swift_23)

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDate/Commons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public enum WeekDay: Int {
/// want to save.
///
/// - returns: the instance you have created into the current thread
internal func localThreadSingleton<T: AnyObject>(key: String, create: (Void) -> T) -> T {
internal func localThreadSingleton<T: AnyObject>(key: String, create: () -> T) -> T {
if let cachedObj = Thread.current.threadDictionary[key] as? T {
return cachedObj
} else {
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftDate/DOTNETDateTimeFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public class DOTNETDateTimeFormatter {
return nil
}

guard let milliseconds = TimeInterval((string as NSString).substring(with: match.rangeAt(1))) else { return nil }
guard let milliseconds = TimeInterval((string as NSString).substring(with: match.range(at: 1))) else { return nil }

// Parse timezone
let raw_tz = ((string as NSString).substring(with: match.rangeAt(2)) as NSString)
let raw_tz = ((string as NSString).substring(with: match.range(at: 2)) as NSString)
guard raw_tz.length > 1 else {
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftDate/DateInRegion+Math.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ extension DateInRegion {
cmps.calendar!.locale = region!.locale
cmps.timeZone = region!.timeZone
}
values.forEach { key,value in
if key != .timeZone && key != .calendar {
cmps.setValue( (multipler == nil ? value : value * multipler!), for: key)
values.forEach { pair in
if pair.key != .timeZone && pair.key != .calendar {
cmps.setValue( (multipler == nil ? pair.value : pair.value * multipler!), for: pair.key)
}
}
return cmps
Expand Down Expand Up @@ -137,7 +137,7 @@ public func + (lhs: DateInRegion, rhs: [Calendar.Component : Int]) -> DateInRegi

public func - (lhs: DateInRegion, rhs: [Calendar.Component : Int]) -> DateInRegion {
var invertedCmps: [Calendar.Component : Int] = [:]
rhs.forEach { invertedCmps[$0] = -$1 }
rhs.forEach { invertedCmps[$0.key] = -$0.value }
return lhs + invertedCmps
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftDate/DateInRegion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class DateInRegion: CustomStringConvertible {
var formatter: ISO8601DateTimeFormatter? = nil
if useSharedFormatters == true {
let name = "SwiftDate_\(NSStringFromClass(ISO8601DateTimeFormatter.self))"
formatter = localThreadSingleton(key: name, create: { (Void) -> ISO8601DateTimeFormatter in
formatter = localThreadSingleton(key: name, create: { () -> ISO8601DateTimeFormatter in
return ISO8601DateTimeFormatter()
})
} else {
Expand All @@ -102,7 +102,7 @@ public class DateInRegion: CustomStringConvertible {
var formatter: DateFormatter? = nil
if useSharedFormatters == true {
let name = "SwiftDate_\(NSStringFromClass(DateFormatter.self))"
formatter = localThreadSingleton(key: name, create: { (Void) -> DateFormatter in
formatter = localThreadSingleton(key: name, create: { () -> DateFormatter in
return DateFormatter()
})
} else {
Expand All @@ -129,7 +129,7 @@ public class DateInRegion: CustomStringConvertible {
var formatter: DateIntervalFormatter? = nil
if useSharedFormatters == true {
let name = "SwiftDate_\(NSStringFromClass(DateIntervalFormatter.self))"
formatter = localThreadSingleton(key: name, create: { (Void) -> DateIntervalFormatter in
formatter = localThreadSingleton(key: name, create: { () -> DateIntervalFormatter in
return DateIntervalFormatter()
})
} else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDate/ISO8601Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public struct ISO8601Configuration {
/// Calendar used to generate the date. By default is the current system calendar
var calendar: Calendar = Calendar.current

init(strict: Bool = false, calendar: Calendar? = nil) {
public init(strict: Bool = false, calendar: Calendar? = nil) {
self.strict = strict
self.calendar = calendar ?? Calendar.current
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDate/TimeInterval+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public extension TimeInterval {
let sharedFormatter = shared ?? true
if sharedFormatter == true {
let name = "SwiftDate_\(NSStringFromClass(DateIntervalFormatter.self))"
formatter = localThreadSingleton(key: name, create: { (Void) -> DateComponentsFormatter in
formatter = localThreadSingleton(key: name, create: { () -> DateComponentsFormatter in
return DateComponentsFormatter()
})
} else {
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 = "4.3.0"
s.version = "4.4.0"
s.summary = "The best way to deal with Dates & Time Zones in Swift"
s.homepage = "https://github.com/malcommac/SwiftDate"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
50 changes: 31 additions & 19 deletions SwiftDate.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = SwiftDate;
TargetAttributes = {
375F8FCC1F0EC70C00ECC0FD = {
Expand Down Expand Up @@ -925,7 +925,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.danielemargutti.TestApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -943,7 +943,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.danielemargutti.TestApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -955,14 +955,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -991,7 +997,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -1006,14 +1012,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -1034,7 +1046,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -1061,7 +1073,7 @@
PRODUCT_NAME = SwiftDate;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1083,7 +1095,7 @@
PRODUCT_NAME = SwiftDate;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -1097,7 +1109,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.SwiftDate.SwiftDate-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1111,7 +1123,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.SwiftDate.SwiftDate-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -1133,7 +1145,7 @@
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
Expand All @@ -1157,7 +1169,7 @@
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
Expand All @@ -1181,7 +1193,7 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -1205,7 +1217,7 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -1232,7 +1244,7 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1257,7 +1269,7 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -1273,7 +1285,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.SwiftDate.SwiftDate-macOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1290,7 +1302,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -1303,7 +1315,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.SwiftDate.SwiftDate-tvOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TVOS_DEPLOYMENT_TARGET = 9.1;
};
name = Debug;
Expand All @@ -1318,7 +1330,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TVOS_DEPLOYMENT_TARGET = 9.1;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,9 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down Expand Up @@ -55,6 +57,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Loading

0 comments on commit d8670fa

Please sign in to comment.