-
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.
[Add] 날짜 변환 String extension 추가 (#7)
- Loading branch information
1 parent
a902919
commit 8d155ec
Showing
3 changed files
with
44 additions
and
0 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
28 changes: 28 additions & 0 deletions
28
Tving_CloneProject/Tving_CloneProject/Global/Extensions/String+.swift
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,28 @@ | ||
// | ||
// String+.swift | ||
// Tving_CloneProject | ||
// | ||
// Created by 윤희슬 on 5/31/24. | ||
// | ||
|
||
import Foundation | ||
|
||
extension String { | ||
|
||
static func calculateDate() -> String { | ||
let today = Date() | ||
let calendar = Calendar.current | ||
var dateComponents = DateComponents() | ||
dateComponents.day = -1 | ||
|
||
if let oneDayAgo = calendar.date(byAdding: dateComponents, to: today) { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyyMMdd" | ||
|
||
let oneDayAgoString = dateFormatter.string(from: oneDayAgo) | ||
return oneDayAgoString | ||
} else { | ||
return "" | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
Tving_CloneProject/Tving_CloneProject/Scene/Main/ViewModel/MovieViewModel.swift
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,8 @@ | ||
// | ||
// MovieViewModel.swift | ||
// Tving_CloneProject | ||
// | ||
// Created by 윤희슬 on 5/31/24. | ||
// | ||
|
||
import Foundation |