ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
gps_time.cpp
Go to the documentation of this file.
1#include "gps_time.h"
2#include "esphome/core/log.h"
3
4namespace esphome::gps {
5
6static const char *const TAG = "gps.time";
7
8void GPSTime::from_tiny_gps_(TinyGPSPlus &tiny_gps) {
9 if (!tiny_gps.time.isValid() || !tiny_gps.date.isValid() || !tiny_gps.time.isUpdated() ||
10 !tiny_gps.date.isUpdated() || tiny_gps.date.year() < 2025) {
11 return;
12 }
13
14 ESPTime val{};
15 val.year = tiny_gps.date.year();
16 val.month = tiny_gps.date.month();
17 val.day_of_month = tiny_gps.date.day();
18 val.hour = tiny_gps.time.hour();
19 val.minute = tiny_gps.time.minute();
20 val.second = tiny_gps.time.second();
21 val.recalc_timestamp_utc(false);
22 this->synchronize_epoch_(val.timestamp);
23 this->has_time_ = true;
24}
25
26} // namespace esphome::gps
void from_tiny_gps_(TinyGPSPlus &tiny_gps)
Definition gps_time.cpp:8
void synchronize_epoch_(uint32_t epoch)
Report a unix epoch as current time.
mopeka_std_values val[3]
A more user-friendly version of struct tm from time.h.
Definition time.h:23
uint16_t year
year
Definition time.h:44