diff --git a/HDFwear/Tools/BleMessage+Function.swift b/HDFwear/Tools/BleMessage+Function.swift index d38debf..c7c3b1c 100644 --- a/HDFwear/Tools/BleMessage+Function.swift +++ b/HDFwear/Tools/BleMessage+Function.swift @@ -20,7 +20,11 @@ extension BleMessage { func getTimeCmd() -> Data { let date = DateInRegion().date - let timeBytes: [UInt8] = [UInt8(date.year%100), UInt8(date.month), UInt8(date.day), UInt8(date.hour), UInt8(date.minute), UInt8(date.second)] + let calendar = Calendar.current + let weekday = calendar.component(.weekday, from: date) + // 调整星期表示 + let adjustedWeekday = (weekday == 1) ? 7 : (weekday - 1) + let timeBytes: [UInt8] = [UInt8(date.year%100), UInt8(date.month), UInt8(date.day), UInt8(date.hour), UInt8(date.minute), UInt8(date.second), UInt8(adjustedWeekday)] // return getSendData(cmd: .set, key: .time, bytes: timeBytes) // let a = getPackData(key: .setTime, contentBytes: timeBytes) // let b = createDataPacket(key: .setTime, bytes: timeBytes)