-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overloaded -timePassed method with language agnostic implementation (#…
…486) Overloaded -timePassed method with language agnostic implementation
- Loading branch information
1 parent
8807ee6
commit d132ea3
Showing
5 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// TimePassed.swift | ||
// EZSwiftExtensions | ||
// | ||
// Created by Jaja Yting on 24/08/2018. | ||
// Copyright © 2018 Goktug Yilmaz. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum TimePassed { | ||
|
||
case year(Int) | ||
case month(Int) | ||
case day(Int) | ||
case hour(Int) | ||
case minute(Int) | ||
case second(Int) | ||
case now | ||
} | ||
|
||
extension TimePassed: Equatable { | ||
|
||
public static func ==(lhs: TimePassed, rhs: TimePassed) -> Bool { | ||
|
||
switch(lhs, rhs) { | ||
|
||
case (.year(let a), .year(let b)): | ||
return a == b | ||
|
||
case (.month(let a), .month(let b)): | ||
return a == b | ||
|
||
case (.day(let a), .day(let b)): | ||
return a == b | ||
|
||
case (.hour(let a), .hour(let b)): | ||
return a == b | ||
|
||
case (.minute(let a), .minute(let b)): | ||
return a == b | ||
|
||
case (.second(let a), .second(let b)): | ||
return a == b | ||
|
||
case (.now, .now): | ||
return true | ||
|
||
default: | ||
return false | ||
} | ||
} | ||
} |