feat: Sets up ci workflows
This commit is contained in:
@@ -1,28 +1,53 @@
|
||||
import Dependencies
|
||||
import DependenciesMacros
|
||||
import Foundation
|
||||
|
||||
public extension DependencyValues {
|
||||
var dateFormatter: DateFormatter {
|
||||
get { self[DateFormatter.self] }
|
||||
set { self[DateFormatter.self] = newValue }
|
||||
var dateFormatter: DateFormatterKey {
|
||||
get { self[DateFormatterKey.self] }
|
||||
set { self[DateFormatterKey.self] = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
#if hasFeature(RetroactiveAttribute)
|
||||
extension DateFormatter: @retroactive DependencyKey {
|
||||
@DependencyClient
|
||||
public struct DateFormatterKey: Sendable {
|
||||
public var string: @Sendable (Date?) -> String = { _ in "N/A" }
|
||||
}
|
||||
|
||||
public static var liveValue: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .short
|
||||
return formatter
|
||||
}
|
||||
extension DateFormatterKey: DependencyKey {
|
||||
public static let testValue = Self()
|
||||
|
||||
public static var liveValue: DateFormatterKey {
|
||||
.init(
|
||||
string: { date in
|
||||
guard let date else { return "N/A" }
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.timeZone = TimeZone(identifier: "UTC")
|
||||
formatter.formatOptions = [.withFullDate]
|
||||
return formatter.string(from: date)
|
||||
}
|
||||
)
|
||||
}
|
||||
#else
|
||||
extension DateFormatter: DependencyKey {
|
||||
public static var liveValue: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .short
|
||||
return formatter
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// #if hasFeature(RetroactiveAttribute)
|
||||
// extension DateFormatter: @retroactive DependencyKey {
|
||||
//
|
||||
// public static var liveValue: DateFormatter {
|
||||
// let formatter = DateFormatter()
|
||||
// formatter.dateStyle = .short
|
||||
// return formatter
|
||||
// }
|
||||
// }
|
||||
// #else
|
||||
// extension DateFormatter: DependencyKey {
|
||||
// public static var liveValue: DateFormatter {
|
||||
// let formatter = ISO8601DateFormatter()
|
||||
// formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
// // formatter.dateFormat = "mm/dd/yyyy"
|
||||
// formatter.formatOptions = [.withFullDate]
|
||||
// formatter.timeZone = TimeZone(identifier: "UTC")
|
||||
// return formatter
|
||||
// }
|
||||
// }
|
||||
// #endif
|
||||
|
||||
@@ -104,11 +104,11 @@ struct PurchaseOrderForm: HTML, Sendable {
|
||||
if let purchaseOrder, let createdAt = purchaseOrder.createdAt {
|
||||
div(.class("row")) {
|
||||
label(.class("label col-2")) { "Created:" }
|
||||
h3(.class("col-2")) { dateFormatter.string(from: createdAt) }
|
||||
h3(.class("col-2")) { dateFormatter.string(createdAt) }
|
||||
if let updatedAt = purchaseOrder.updatedAt {
|
||||
div(.class("col-1")) {}
|
||||
label(.class("label col-2")) { "Updated:" }
|
||||
h3(.class("col-2")) { dateFormatter.string(from: updatedAt) }
|
||||
h3(.class("col-2")) { dateFormatter.string(updatedAt) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ struct UserDetail: HTML, Sendable {
|
||||
}
|
||||
div(.class("row")) {
|
||||
span(.class("label col-2")) { "Created:" }
|
||||
span(.class("date col-4")) { dateFormatter.formattedDate(user.createdAt) }
|
||||
span(.class("date col-4")) { dateFormatter.string(user.createdAt) }
|
||||
span(.class("label col-2")) { "Updated:" }
|
||||
span(.class("date col-4")) { dateFormatter.formattedDate(user.updatedAt) }
|
||||
span(.class("date col-4")) { dateFormatter.string(user.updatedAt) }
|
||||
}
|
||||
div(.class("btn-row user-buttons")) {
|
||||
button(
|
||||
|
||||
Reference in New Issue
Block a user