This PR contains the work done to update the library and the attached example project to use the Swift 6.4 computer as a minimum supported version and also, to use the latest features introduced in it. Reviewed-on: #1 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
48 lines
1.4 KiB
Swift
48 lines
1.4 KiB
Swift
internal import CPlaydate
|
|
|
|
extension System {
|
|
/// A calendar date and time. Mirrors `PDDateTime`.
|
|
public struct DateTime: Sendable {
|
|
/// Full year, e.g. 2026.
|
|
public var year: UInt16
|
|
/// 1...12.
|
|
public var month: UInt8
|
|
/// 1...31.
|
|
public var day: UInt8
|
|
/// 1 (Monday)...7 (Sunday); 0 when unset.
|
|
public var weekday: UInt8
|
|
/// 0...23.
|
|
public var hour: UInt8
|
|
/// 0...59.
|
|
public var minute: UInt8
|
|
/// 0...59.
|
|
public var second: UInt8
|
|
|
|
public init(year: UInt16, month: UInt8, day: UInt8, weekday: UInt8 = 0,
|
|
hour: UInt8, minute: UInt8, second: UInt8) {
|
|
self.year = year
|
|
self.month = month
|
|
self.day = day
|
|
self.weekday = weekday
|
|
self.hour = hour
|
|
self.minute = minute
|
|
self.second = second
|
|
}
|
|
|
|
init(_ dateTime: PDDateTime) {
|
|
year = dateTime.year
|
|
month = dateTime.month
|
|
day = dateTime.day
|
|
weekday = dateTime.weekday
|
|
hour = dateTime.hour
|
|
minute = dateTime.minute
|
|
second = dateTime.second
|
|
}
|
|
|
|
var cValue: PDDateTime {
|
|
PDDateTime(year: year, month: month, day: day, weekday: weekday,
|
|
hour: hour, minute: minute, second: second)
|
|
}
|
|
}
|
|
}
|