From 7a9ecfe866f06eac9b9e76a2ddd6783471c589e0 Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 12 Nov 2023 13:35:33 +0800 Subject: [PATCH] feat:set time parameter --- HDFwear/Tools/BleMessage+Function.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) -- libgit2 0.21.4