Christian Risi f3bc5f32e2 V0.6.2 Arroyo Toad
Fixed timeconversion to support unixepoch timestamp
2024-12-06 19:08:29 +00:00

36 lines
913 B
Swift

import Foundation
public extension Data {
var uint8 : UInt8 {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt8.self) }[0]
}
var uint16: UInt16 {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt16.self) }[0]
}
var uint32: UInt32 {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt32.self) }[0]
}
var uint64: UInt64 {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt64.self) }[0]
}
var uint128: UInt128 {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt128.self) }[0]
}
var uint: UInt {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt.self) }[0]
}
var timestamp: Date {
return self.withUnsafeBytes{ $0.bindMemory(to: Date.self) }[0]
}
var double: Double {
return self.withUnsafeBytes{ $0.bindMemory(to: Double.self) }[0]
}
}