adds first version of the app

This commit is contained in:
2026-10-17 14:33:43 +02:00
parent ab1abadcd1
commit 7b891819b0
3066 changed files with 29585 additions and 0 deletions
@@ -0,0 +1,29 @@
import Foundation
import PlakCore
import Testing
@Suite struct CreatedDateTests {
private let zone = TimeZone(identifier: "Europe/Amsterdam")!
private func date(_ year: Int, _ month: Int, _ day: Int, _ hour: Int, _ minute: Int) -> Date {
var calendar = Calendar(identifier: .gregorian)
calendar.timeZone = zone
return calendar.date(from: DateComponents(year: year, month: month, day: day, hour: hour, minute: minute))!
}
@Test("the label is day, short Dutch month and time, with the year only when it is not this year")
func label() {
let now = date(2026, 10, 16, 12, 0)
#expect(CreatedDate.label(for: date(2026, 10, 16, 8, 55), now: now, timeZone: zone) == "16 okt 08:55")
#expect(CreatedDate.label(for: date(2025, 3, 3, 14, 2), now: now, timeZone: zone) == "3 mrt 2025 14:02")
#expect(CreatedDate.label(for: date(2026, 5, 1, 0, 7), now: now, timeZone: zone) == "1 mei 00:07")
let months = (1...12).map { CreatedDate.label(for: date(2026, $0, 9, 9, 9), now: now, timeZone: zone) }
#expect(months.map { $0.split(separator: " ")[1] } == ["jan", "feb", "mrt", "apr", "mei", "jun", "jul", "aug", "sep", "okt", "nov", "dec"])
}
@Test("the date line is local time to the minute")
func line() {
#expect(CreatedDate.line(for: date(2026, 10, 16, 8, 55).addingTimeInterval(42), timeZone: zone) == "<!-- 2026-10-16 08:55 -->")
#expect(CreatedDate.date(fromLine: "<!-- 2026-10-16 08:55 -->", timeZone: zone) == date(2026, 10, 16, 8, 55))
}
}