From 0b6ebf95e30a74b29083060304088f499a0393d8 Mon Sep 17 00:00:00 2001 From: pNre Date: Sun, 12 Apr 2015 12:32:59 +0200 Subject: [PATCH] Updated NSDate for iOS8 --- ExSwift/NSDate.swift | 4 +++- ExSwiftTests/StringExtensionsTests.swift | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ExSwift/NSDate.swift b/ExSwift/NSDate.swift index db1a49b..c699289 100644 --- a/ExSwift/NSDate.swift +++ b/ExSwift/NSDate.swift @@ -26,8 +26,10 @@ public extension NSDate { */ public func add(seconds: Int = 0, minutes: Int = 0, hours: Int = 0, days: Int = 0, weeks: Int = 0, months: Int = 0, years: Int = 0) -> NSDate { var calendar = NSCalendar.currentCalendar() + let version = floor(NSFoundationVersionNumber) - if ( version <= NSFoundationVersionNumber_iOS_7_1 || version <= NSFoundationVersionNumber10_9_2 ) { + + if version <= NSFoundationVersionNumber10_9_2 { var component = NSDateComponents() component.setValue(seconds, forComponent: .CalendarUnitSecond) diff --git a/ExSwiftTests/StringExtensionsTests.swift b/ExSwiftTests/StringExtensionsTests.swift index dc14fce..c04bbb1 100644 --- a/ExSwiftTests/StringExtensionsTests.swift +++ b/ExSwiftTests/StringExtensionsTests.swift @@ -275,7 +275,7 @@ class StringExtensionsSpec: QuickSpec { c.month = 8 c.day = 19 - var gregorian = NSCalendar(identifier: NSGregorianCalendar)! + var gregorian = NSCalendar(identifier: NSCalendarIdentifierGregorian)! expect(gregorian.dateFromComponents(c)) == d expect("a772.2".toDate()).to(beNil()) @@ -296,7 +296,7 @@ class StringExtensionsSpec: QuickSpec { c.minute = 4 c.second = 34 - var gregorian = NSCalendar(identifier: NSGregorianCalendar)! + var gregorian = NSCalendar(identifier: NSCalendarIdentifierGregorian)! expect(gregorian.dateFromComponents(c)) == d expect("a772.2".toDateTime()).to(beNil())