Files
oai-swift/oAI/Models/HistoryEntry.swift

54 lines
1.6 KiB
Swift

//
// HistoryEntry.swift
// oAI
//
// Command history entry model
//
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2026 Rune Olsen
//
// This file is part of oAI.
//
// oAI is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// oAI is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
// Public License for more details.
//
// You should have received a copy of the GNU Affero General Public
// License along with oAI. If not, see <https://www.gnu.org/licenses/>.
import Foundation
struct HistoryEntry: Identifiable, Equatable {
let id = UUID()
let input: String
let timestamp: Date
/// Format timestamp in European format (dd.MM.yyyy HH:mm:ss)
var formattedDate: String {
let formatter = DateFormatter()
formatter.dateFormat = "dd.MM.yyyy HH:mm:ss"
return formatter.string(from: timestamp)
}
/// Short date without time (dd.MM.yyyy)
var shortDate: String {
let formatter = DateFormatter()
formatter.dateFormat = "dd.MM.yyyy"
return formatter.string(from: timestamp)
}
/// Just the time (HH:mm:ss)
var timeOnly: String {
let formatter = DateFormatter()
formatter.dateFormat = "HH:mm:ss"
return formatter.string(from: timestamp)
}
}