1import 'package:blood_pressure_app/features/old_bluetooth/logic/characteristics/decoding_util.dart';
 2
 3extension BleDateTimeParser on DateTime {
 4  static DateTime? parseBle(List<int> bytes, int offset) {
 5    if (bytes.length < offset + 7) return null;
 6
 7    final int? year = readUInt16Le(bytes, offset);
 8    offset += 2;
 9    final int? month = readUInt8(bytes, offset);
10    offset += 1;
11    final int? day = readUInt8(bytes, offset);
12    offset += 1;
13    final int? hourOfDay = readUInt8(bytes, offset);
14    offset += 1;
15    final int? minute = readUInt8(bytes, offset);
16    offset += 1;
17    final int? second = readUInt8(bytes, offset);
18
19    if (year == null
20      || month == null
21      || day == null
22      || hourOfDay == null
23      || minute == null
24      || second == null) return null;
25
26    if (year <= 0
27      || month <= 0
28      || day <= 0) return null;
29
30    return DateTime(year, month, day, hourOfDay, minute, second);
31  }
32}