35 lines
869 B
C
35 lines
869 B
C
//
|
|
// Created by villuton on 20.03.25.
|
|
//
|
|
#include <stdbool.h>
|
|
#include "Nmea0183Parser_General.h"
|
|
#include "Nmea0183Parser_Private.h"
|
|
|
|
bool Nmea0183ParseTime(char *utcString, char const *utcStringEnd, tNmeaTime *time) {
|
|
|
|
uint32_t len = utcStringEnd - utcString;
|
|
uint8_t charsLeft = len - 7;
|
|
|
|
if (len > 10 || len < 9) {
|
|
return false;
|
|
}
|
|
|
|
if (utcString[6] != '.') {
|
|
return false;
|
|
}
|
|
|
|
time->hour = Nmea0183ParseShortCharsDecimalNumber(utcString + 0, 2);
|
|
time->minute = Nmea0183ParseShortCharsDecimalNumber(utcString + 2, 2);
|
|
time->second = Nmea0183ParseShortCharsDecimalNumber(utcString + 4, 2);
|
|
|
|
time->millisecond = Nmea0183ParseShortCharsDecimalNumber(utcString + 7, charsLeft);
|
|
|
|
charsLeft = 3 - charsLeft;
|
|
|
|
while (charsLeft) {
|
|
time->millisecond *= 10;
|
|
--charsLeft;
|
|
}
|
|
|
|
return true;
|
|
} |