[스위프트3] 날짜 비교
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/**
Date를 비교
- parameters:
- a : A DateString
- b : B DateString
- format : A와 B의 String Format
- returns : A > B = 1, A = B = 0, A < B = -1
*/
static func compare_Date_A_To_B(a:String, b:String, format:String) -> Int{
let formattor:DateFormatter = DateFormatter()
formattor.dateFormat = format
formattor.locale = Locale(identifier: "ko_KR")
let A:Date = formattor.date(from: a)!
let B:Date = formattor.date(from: b)!
switch A.compare(B) {
case .orderedAscending:
return 1
case .orderedDescending:
return -1
default:
return 0
}
}
| cs |
댓글
댓글 쓰기