-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from idorm/feat/postList/detail
[Feat] PostList Detail 작업
- Loading branch information
Showing
8 changed files
with
99 additions
and
5 deletions.
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
Binary file modified
BIN
-982 Bytes
(100%)
idorm.xcworkspace/xcuserdata/eungcheol.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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,41 @@ | ||
// | ||
// TimeManager.swift | ||
// idorm | ||
// | ||
// Created by 김응철 on 2023/01/20. | ||
// | ||
|
||
import Foundation | ||
|
||
enum TimeManager { | ||
|
||
static func postList(_ string: String) -> String { | ||
let result: String | ||
|
||
let format = DateFormatter() | ||
format.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'" | ||
format.timeZone = .init(abbreviation: "UTC") | ||
|
||
let postDate = format.date(from: string)! | ||
let currentDate = format.date(from: Date().ISO8601Format())! | ||
|
||
let interval = Int(currentDate.timeIntervalSince(postDate)) | ||
|
||
switch interval { | ||
case 0..<60: | ||
result = "방금" | ||
|
||
case 60..<3600: | ||
result = "\(interval / 60)분 전" | ||
|
||
case 3600..<86400: | ||
result = "\(interval / 3600)시간 전" | ||
|
||
default: | ||
format.dateFormat = "MM/dd" | ||
result = format.string(from: postDate) | ||
} | ||
|
||
return result | ||
} | ||
} |
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