45 lines
1.2 KiB
Swift
45 lines
1.2 KiB
Swift
//
|
|
// VehiclePhotoDto.swift
|
|
// AutoCatCore
|
|
//
|
|
// Created by Selim Mustafaev on 12.06.2024.
|
|
// Copyright © 2024 Selim Mustafaev. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public struct VehiclePhotoDto: Decodable, Sendable, Equatable, Identifiable, Hashable {
|
|
|
|
public let id = UUID()
|
|
public var brand: String?
|
|
public var model: String?
|
|
public var date: TimeInterval = 0
|
|
public var url: String = ""
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
|
|
case brand, model, date, url
|
|
}
|
|
|
|
public var description: String {
|
|
let formatter = DateFormatter()
|
|
formatter.timeZone = TimeZone(identifier:"GMT")
|
|
formatter.dateStyle = .medium
|
|
formatter.timeStyle = .none
|
|
let date = Date(timeIntervalSince1970: self.date/1000)
|
|
let dateStr = formatter.string(from: date)
|
|
return "\(self.brand ?? "") \(self.model ?? "") (\(dateStr))"
|
|
}
|
|
|
|
public init(brand: String? = nil,
|
|
model: String? = nil,
|
|
date: TimeInterval,
|
|
url: String) {
|
|
|
|
self.brand = brand
|
|
self.model = model
|
|
self.date = date
|
|
self.url = url
|
|
}
|
|
}
|