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

Commit

Permalink
Fixed bug on operator > in NSDate
Browse files Browse the repository at this point in the history
  • Loading branch information
PGLongo committed Jan 11, 2015
1 parent dfac920 commit 51fb44a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ExSwift/NSDate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ public extension NSDate{
public func getComponent (component : NSCalendarUnit) -> Int {
let calendar = NSCalendar.currentCalendar()
let components = calendar.components(component, fromDate: self)

return components.valueForComponent(component)
}
}
Expand All @@ -239,7 +240,7 @@ public func <(lhs: NSDate, rhs: NSDate) -> Bool {
}

public func >(lhs: NSDate, rhs: NSDate) -> Bool {
return !(lhs < rhs)
return !(lhs <= rhs)
}

public func <=(lhs: NSDate, rhs: NSDate) -> Bool {
Expand Down
2 changes: 2 additions & 0 deletions ExSwiftTests/ExSwiftNSDateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,11 @@ class ExSwiftNSDataTests: XCTestCase {

XCTAssertTrue(startDate > date, "Date should be greater")
XCTAssertFalse(startDate > anotherDate, "Date shouldn't be greater")
XCTAssertFalse(startDate > shouldBeTheSameDate, "Date shouldn't be greater")

XCTAssertTrue(startDate < anotherDate, "Date should be lower")
XCTAssertFalse(startDate < date, "Date shouldn't be lower")
XCTAssertFalse(startDate < shouldBeTheSameDate, "Date shouldn't be lower")

XCTAssertTrue(startDate >= shouldBeTheSameDate, "Date should be greater or equal")
XCTAssertTrue(startDate >= date, "Date should be greater or equal")
Expand Down

0 comments on commit 51fb44a

Please sign in to comment.