Screaming-Reminder/Screaming Reminder/Models/Reminder.swift

34 lines
701 B
Swift
Raw Normal View History

2024-07-11 10:38:11 +00:00
//
// Reminder.swift
// Screaming Reminder
//
// Created by Amine Bou on 11/07/2024.
//
import SwiftUI
import SwiftData
@Model
final class Reminder: CustomStringConvertible {
var label: String
var when: [Date]
required init(label: String, when: [Date]) {
self.label = label
self.when = when
}
public var description: String {
let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.timeStyle = .short
return formatter
}()
let smallestDate = self.when.sorted()[0]
return "\(label) - Tous les jours, à partir de \(dateFormatter.string(from: smallestDate))"
}
}