33 lines
970 B
Swift
33 lines
970 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.autoupdatingCurrent
|
|
formatter.timeZone = TimeZone.current
|
|
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)
|
|
}
|
|
}
|