42 lines
828 B
Swift
42 lines
828 B
Swift
//
|
|
// DateAdapter.swift
|
|
// Profile
|
|
//
|
|
// Created by Javier Cicchelli on 12/12/2022.
|
|
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
struct DateAdapter {
|
|
|
|
// MARK: Properties
|
|
|
|
private let dateFormatter: DateFormatter = .dateTimeFormatter
|
|
|
|
// MARK: Functions
|
|
|
|
func callAsFunction(value: Date?) -> String {
|
|
if let value {
|
|
return dateFormatter.string(from: value)
|
|
} else {
|
|
return .Constants.noValue
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - DateFormatter+Formats
|
|
|
|
private extension DateFormatter {
|
|
static let dateTimeFormatter = {
|
|
let formatter = DateFormatter()
|
|
|
|
formatter.dateStyle = .long
|
|
formatter.timeStyle = .short
|
|
formatter.locale = .current
|
|
|
|
return formatter
|
|
}()
|
|
}
|