Files
sodalive-ios/SodaLive/Sources/Extensions/DateExtension.swift
Yu Sung 2f8331f2ff 라이브 시작시간 UTC 적용
라이브 상세와 수정 화면에서 UTC 기준 시간을 표시한다.
날짜 표기는 OS 언어 설정의 기본 포맷을 사용한다.
2026-01-05 11:36:26 +09:00

32 lines
922 B
Swift

//
// DateExtension.swift
// SodaLive
//
// Created by klaus on 2022/05/27.
//
import Foundation
extension Date {
func convertDateFormat(dateFormat: String = "yyyy.MM.dd") -> String {
let formatter = DateFormatter()
formatter.dateFormat = dateFormat
formatter.locale = Locale(identifier: "ko")
return formatter.string(from: self)
}
func localizedDateTimeString(dateStyle: DateFormatter.Style = .medium,
timeStyle: DateFormatter.Style = .short) -> String {
let formatter = DateFormatter()
formatter.dateStyle = dateStyle
formatter.timeStyle = timeStyle
formatter.locale = Locale.autoupdatingCurrent
formatter.timeZone = TimeZone.current
return formatter.string(from: self)
}
func currentTimeMillis() -> Int64 {
return Int64(self.timeIntervalSince1970 * 1000)
}
}