34 lines
701 B
Swift
34 lines
701 B
Swift
|
//
|
||
|
// 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))"
|
||
|
}
|
||
|
}
|