feat:调整校准时间逻辑
This commit is contained in:
parent
cd00d3159d
commit
e1b9c1868e
@ -50,10 +50,25 @@ class LockTimeLogic extends BaseGetXController {
|
||||
|
||||
// 有效时间
|
||||
final List<int> indate = reply.data.sublist(150, 154);
|
||||
final int indateValue = (0xff & indate[0]) << 24 |
|
||||
int indateValue = (0xff & indate[0]) << 24 |
|
||||
(0xff & indate[1]) << 16 |
|
||||
(0xff & indate[2]) << 8 |
|
||||
(0xFF & indate[3]);
|
||||
// 检查时间戳是否无效或超出范围
|
||||
if (indateValue == 0xffffffff || indateValue <= 0) {
|
||||
// 使用当前系统时间戳(秒)
|
||||
indateValue = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
AppLog.log('检测到无效时间戳,使用系统时间:$indateValue');
|
||||
}
|
||||
|
||||
// 验证时间戳是否在合理范围内(例如:2000年到2100年之间)
|
||||
final DateTime dateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(indateValue * 1000);
|
||||
if (dateTime.year < 2000 || dateTime.year > 2100) {
|
||||
AppLog.log('时间戳超出合理范围: $indateValue');
|
||||
indateValue = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
}
|
||||
|
||||
AppLog.log(
|
||||
'====================indate:$indate indateValue:$indateValue');
|
||||
state.dateTime.value = DateTool().dateToYMDHNString('$indateValue');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user