Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

Commit

Permalink
Updated NSDate for iOS8
Browse files Browse the repository at this point in the history
  • Loading branch information
pNre committed Apr 12, 2015
1 parent 8beeb7f commit 0b6ebf9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ExSwift/NSDate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions ExSwiftTests/StringExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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())
Expand Down

0 comments on commit 0b6ebf9

Please sign in to comment.