NetBurner 3.5.6
PDF Version
GPSTime.h
1#pragma once
2class GPSTime
3{
4 public:
5 // time
6 int hours;
7 int minutes;
8 int seconds;
9 int milliseconds;
10
11 // date
12 int day;
13 int month;
14 int year;
15
16 GPSTime();
17
18 // Set from NMEA-style time string: hhmmss[.sss]
19 void setFromNMEATime(const char *timeStr);
20 // Set from NMEA-style date string: ddmmyy
21 void setFromNMEADate(const char *dateStr);
22
23 // Get formatted time strings
24 void getTimeString(char *buffer) const; // "HH:mm:ss"
25 void getTimeStringWithMillis(char *buffer) const; // "HH:mm:ss.sss"
26 void getTimeISOStringWithMillis(char *buffer) const; // "YYYY-MM-DDTHH:mm:ss.sss"
27
28 // Utility
29 bool isValid() const;
30 void reset();
31 int getEpochTime() const
32 {
33 return (year - 1970) * 365 * 24 * 3600 + (month - 1) * 30 * 24 * 3600 + (day - 1) * 24 * 3600 + hours * 3600 + minutes * 60 +
34 seconds;
35 }
36};