// SPDX-FileCopyrightText: 2026 Kaede Akino // SPDX-License-Identifier: GPL-3.0-only import Foundation nonisolated public enum ChatMessageTimestampFormatter { public static func string( for date: Date, now: Date = .now, calendar: Calendar = .autoupdatingCurrent, locale: Locale = .autoupdatingCurrent, timeZone: TimeZone = .autoupdatingCurrent ) -> String { let formatter = DateFormatter() var calendar = calendar calendar.timeZone = timeZone formatter.calendar = calendar formatter.locale = locale formatter.timeZone = timeZone formatter.dateStyle = calendar.isDate(date, inSameDayAs: now) ? .none : .short formatter.timeStyle = .short return formatter.string(from: date) } }