Commit 7a9ecfe866f06eac9b9e76a2ddd6783471c589e0

Authored by jason
1 parent 8e7dca7e

feat:set time parameter

HDFwear/Tools/BleMessage+Function.swift
... ... @@ -20,7 +20,11 @@ extension BleMessage {
20 20  
21 21 func getTimeCmd() -> Data {
22 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 28 // return getSendData(cmd: .set, key: .time, bytes: timeBytes)
25 29 // let a = getPackData(key: .setTime, contentBytes: timeBytes)
26 30 // let b = createDataPacket(key: .setTime, bytes: timeBytes)
... ...