Commit 7a9ecfe866f06eac9b9e76a2ddd6783471c589e0
1 parent
8e7dca7e
feat:set time parameter
Showing
1 changed file
with
5 additions
and
1 deletions
HDFwear/Tools/BleMessage+Function.swift
@@ -20,7 +20,11 @@ extension BleMessage { | @@ -20,7 +20,11 @@ extension BleMessage { | ||
20 | 20 | ||
21 | func getTimeCmd() -> Data { | 21 | func getTimeCmd() -> Data { |
22 | let date = DateInRegion().date | 22 | let date = DateInRegion().date |
23 | - let timeBytes: [UInt8] = [UInt8(date.year%100), UInt8(date.month), UInt8(date.day), UInt8(date.hour), UInt8(date.minute), UInt8(date.second)] | 23 | + let calendar = Calendar.current |
24 | + let weekday = calendar.component(.weekday, from: date) | ||
25 | + // 调整星期表示 | ||
26 | + let adjustedWeekday = (weekday == 1) ? 7 : (weekday - 1) | ||
27 | + let timeBytes: [UInt8] = [UInt8(date.year%100), UInt8(date.month), UInt8(date.day), UInt8(date.hour), UInt8(date.minute), UInt8(date.second), UInt8(adjustedWeekday)] | ||
24 | // return getSendData(cmd: .set, key: .time, bytes: timeBytes) | 28 | // return getSendData(cmd: .set, key: .time, bytes: timeBytes) |
25 | // let a = getPackData(key: .setTime, contentBytes: timeBytes) | 29 | // let a = getPackData(key: .setTime, contentBytes: timeBytes) |
26 | // let b = createDataPacket(key: .setTime, bytes: timeBytes) | 30 | // let b = createDataPacket(key: .setTime, bytes: timeBytes) |