diff options
| author | JF <jf@codingfield.com> | 2020-03-03 18:59:01 (GMT) |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2020-03-03 18:59:01 (GMT) |
| commit | 545636940f68108a361dda85e0e48a240909cf29 (patch) | |
| tree | f471cf8f60976ab1fffce747db021e5706bf60c2 /src/Components/DateTime/DateTimeController.cpp | |
| parent | 79b4f006be8732663706f1177e17e52829eb661f (diff) | |
| parent | d2f725ec9bc6d848906b83ca539d873223d74648 (diff) | |
Merge branch 'littlevgl'
# Conflicts:
# src/DisplayApp/Screens/Clock.cpp
# src/DisplayApp/Screens/Clock.h
Diffstat (limited to 'src/Components/DateTime/DateTimeController.cpp')
| -rw-r--r-- | src/Components/DateTime/DateTimeController.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/Components/DateTime/DateTimeController.cpp b/src/Components/DateTime/DateTimeController.cpp index ed6d70f..5cfa08e 100644 --- a/src/Components/DateTime/DateTimeController.cpp +++ b/src/Components/DateTime/DateTimeController.cpp @@ -7,25 +7,23 @@ using namespace Pinetime::Controllers; void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t dayOfWeek, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter) { + std::tm tm = { /* .tm_sec = */ second, + /* .tm_min = */ minute, + /* .tm_hour = */ hour, + /* .tm_mday = */ day, + /* .tm_mon = */ month - 1, + /* .tm_year = */ year - 1900, + }; + tm.tm_isdst = -1; // Use DST value from local time zone + currentDateTime = std::chrono::system_clock::from_time_t(std::mktime(&tm)); - currentDateTime = {}; - currentDateTime += date::years( year-1970); - currentDateTime += date::days( day - 1); - currentDateTime += date::months( month - 1); - - currentDateTime += std::chrono::hours(hour); - currentDateTime += std::chrono::minutes (minute); - currentDateTime += std::chrono::seconds (second); - - currentDateTime -= std::chrono::hours(3); // TODO WHYYYY? NRF_LOG_INFO("%d %d %d ", day, month, year); NRF_LOG_INFO("%d %d %d ", hour, minute, second); previousSystickCounter = systickCounter; + UpdateTime(systickCounter); NRF_LOG_INFO("* %d %d %d ", this->hour, this->minute, this->second); NRF_LOG_INFO("* %d %d %d ", this->day, this->month, this->year); - - } void DateTime::UpdateTime(uint32_t systickCounter) { |
