date: Remove date lib
DateTimeController can provide everything we need.
This commit is contained in:
parent
959778d770
commit
8baa317e7e
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -7,6 +7,3 @@
|
|||
[submodule "src/libs/QCBOR"]
|
||||
path = src/libs/QCBOR
|
||||
url = https://github.com/laurencelundblade/QCBOR.git
|
||||
[submodule "src/libs/date"]
|
||||
path = src/libs/date
|
||||
url = https://github.com/HowardHinnant/date.git
|
||||
|
|
|
@ -658,14 +658,6 @@ set(INCLUDE_FILES
|
|||
drivers/Cst816s.h
|
||||
FreeRTOS/portmacro.h
|
||||
FreeRTOS/portmacro_cmsis.h
|
||||
libs/date/include/date/tz.h
|
||||
libs/date/include/date/chrono_io.h
|
||||
libs/date/include/date/date.h
|
||||
libs/date/include/date/islamic.h
|
||||
libs/date/include/date/iso_week.h
|
||||
libs/date/include/date/julian.h
|
||||
libs/date/include/date/ptz.h
|
||||
libs/date/include/date/tz_private.h
|
||||
displayapp/LittleVgl.h
|
||||
displayapp/InfiniTimeTheme.h
|
||||
systemtask/SystemTask.h
|
||||
|
@ -690,7 +682,6 @@ include_directories(
|
|||
include_directories(SYSTEM
|
||||
libs/
|
||||
FreeRTOS/
|
||||
libs/date/include
|
||||
libs/mynewt-nimble/porting/npl/freertos/include
|
||||
libs/mynewt-nimble/nimble/include
|
||||
libs/mynewt-nimble/porting/nimble/include
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include <qcbor/qcbor_spiffy_decode.h>
|
||||
#include "WeatherService.h"
|
||||
#include "libs/QCBOR/inc/qcbor/qcbor.h"
|
||||
|
|
|
@ -67,6 +67,10 @@ namespace Pinetime {
|
|||
return static_cast<Days>(daysSinceSunday);
|
||||
}
|
||||
|
||||
uint8_t DayOfYear() const {
|
||||
return localTime.tm_yday + 1;
|
||||
}
|
||||
|
||||
uint8_t Hours() const {
|
||||
return localTime.tm_hour;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
#include <FreeRTOS.h>
|
||||
#include <date/date.h>
|
||||
#include <queue.h>
|
||||
#include <task.h>
|
||||
#include <memory>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <queue.h>
|
||||
#include "components/gfx/Gfx.h"
|
||||
#include "drivers/Cst816s.h"
|
||||
#include <date/date.h>
|
||||
#include <drivers/Watchdog.h>
|
||||
#include <components/motor/MotorController.h>
|
||||
#include "BootErrors.h"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "displayapp/screens/Clock.h"
|
||||
|
||||
#include <date/date.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include "components/battery/BatteryController.h"
|
||||
#include "components/motion/MotionController.h"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <FreeRTOS.h>
|
||||
#include <algorithm>
|
||||
#include <task.h>
|
||||
#include "displayapp/screens/SystemInfo.h"
|
||||
#include <lvgl/lvgl.h>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||
|
||||
#include <date/date.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <cstdio>
|
||||
#include "displayapp/screens/BatteryIcon.h"
|
||||
|
@ -225,19 +224,14 @@ void WatchFaceCasioStyleG7710::Refresh() {
|
|||
currentDateTime = dateTimeController.CurrentDateTime();
|
||||
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
auto newDateTime = currentDateTime.Get();
|
||||
auto hour = dateTimeController.Hours();
|
||||
auto minute = dateTimeController.Minutes();
|
||||
auto year = dateTimeController.Year();
|
||||
auto month = dateTimeController.Month();
|
||||
auto dayOfWeek = dateTimeController.DayOfWeek();
|
||||
auto day = dateTimeController.Day();
|
||||
auto dayOfYear = dateTimeController.DayOfYear();
|
||||
|
||||
auto dp = date::floor<date::days>(newDateTime);
|
||||
auto time = date::make_time(newDateTime - dp);
|
||||
auto yearMonthDay = date::year_month_day(dp);
|
||||
|
||||
auto year = static_cast<int>(yearMonthDay.year());
|
||||
auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
|
||||
auto day = static_cast<unsigned>(yearMonthDay.day());
|
||||
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
|
||||
|
||||
uint8_t hour = time.hours().count();
|
||||
uint8_t minute = time.minutes().count();
|
||||
auto weekNumberFormat = "%V";
|
||||
|
||||
if (displayedHour != hour || displayedMinute != minute) {
|
||||
|
@ -278,22 +272,19 @@ void WatchFaceCasioStyleG7710::Refresh() {
|
|||
// first day of week 1; days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]
|
||||
}
|
||||
|
||||
uint8_t weekNumber;
|
||||
uint16_t dayOfYearNumber, daysTillEndOfYearNumber;
|
||||
|
||||
time_t ttTime =
|
||||
std::chrono::system_clock::to_time_t(std::chrono::time_point_cast<std::chrono::system_clock::duration>(currentDateTime.Get()));
|
||||
tm* tmTime = std::localtime(&ttTime);
|
||||
|
||||
dayOfYearNumber = tmTime->tm_yday + 1; // tm_yday day of year [0,365] => yday+1
|
||||
daysTillEndOfYearNumber = (yearMonthDay.year().is_leap() ? 366 : 365) - dayOfYearNumber;
|
||||
int daysInCurrentYear = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0 ? 366 : 365;
|
||||
uint16_t daysTillEndOfYearNumber = daysInCurrentYear - dayOfYear;
|
||||
|
||||
char buffer[8];
|
||||
strftime(buffer, 8, weekNumberFormat, tmTime);
|
||||
weekNumber = atoi(buffer);
|
||||
uint8_t weekNumber = atoi(buffer);
|
||||
|
||||
lv_label_set_text_fmt(label_day_of_week, "%s", dateTimeController.DayOfWeekShortToString());
|
||||
lv_label_set_text_fmt(label_day_of_year, "%3d-%3d", dayOfYearNumber, daysTillEndOfYearNumber);
|
||||
lv_label_set_text_fmt(label_day_of_year, "%3d-%3d", dayOfYear, daysTillEndOfYearNumber);
|
||||
lv_label_set_text_fmt(label_week_number, "WK%02d", weekNumber);
|
||||
|
||||
lv_obj_realign(label_day_of_week);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "displayapp/screens/WatchFaceDigital.h"
|
||||
|
||||
#include <date/date.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <cstdio>
|
||||
#include "displayapp/screens/NotificationIcon.h"
|
||||
|
@ -89,19 +88,12 @@ void WatchFaceDigital::Refresh() {
|
|||
currentDateTime = dateTimeController.CurrentDateTime();
|
||||
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
auto newDateTime = currentDateTime.Get();
|
||||
|
||||
auto dp = date::floor<date::days>(newDateTime);
|
||||
auto time = date::make_time(newDateTime - dp);
|
||||
auto yearMonthDay = date::year_month_day(dp);
|
||||
|
||||
auto year = static_cast<int>(yearMonthDay.year());
|
||||
auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
|
||||
auto day = static_cast<unsigned>(yearMonthDay.day());
|
||||
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
|
||||
|
||||
uint8_t hour = time.hours().count();
|
||||
uint8_t minute = time.minutes().count();
|
||||
auto hour = dateTimeController.Hours();
|
||||
auto minute = dateTimeController.Minutes();
|
||||
auto year = dateTimeController.Year();
|
||||
auto month = dateTimeController.Month();
|
||||
auto dayOfWeek = dateTimeController.DayOfWeek();
|
||||
auto day = dateTimeController.Day();
|
||||
|
||||
if (displayedHour != hour || displayedMinute != minute) {
|
||||
displayedHour = hour;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "displayapp/screens/WatchFaceInfineat.h"
|
||||
|
||||
#include <date/date.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <cstdio>
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
|
@ -314,19 +313,12 @@ void WatchFaceInfineat::Refresh() {
|
|||
currentDateTime = dateTimeController.CurrentDateTime();
|
||||
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
auto newDateTime = currentDateTime.Get();
|
||||
|
||||
auto dp = date::floor<date::days>(newDateTime);
|
||||
auto time = date::make_time(newDateTime - dp);
|
||||
auto yearMonthDay = date::year_month_day(dp);
|
||||
|
||||
auto year = static_cast<int>(yearMonthDay.year());
|
||||
auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
|
||||
auto day = static_cast<unsigned>(yearMonthDay.day());
|
||||
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
|
||||
|
||||
int hour = time.hours().count();
|
||||
auto minute = time.minutes().count();
|
||||
auto hour = dateTimeController.Hours();
|
||||
auto minute = dateTimeController.Minutes();
|
||||
auto year = dateTimeController.Year();
|
||||
auto month = dateTimeController.Month();
|
||||
auto dayOfWeek = dateTimeController.DayOfWeek();
|
||||
auto day = dateTimeController.Day();
|
||||
|
||||
char minutesChar[3];
|
||||
sprintf(minutesChar, "%02d", static_cast<int>(minute));
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*/
|
||||
|
||||
#include "displayapp/screens/WatchFacePineTimeStyle.h"
|
||||
#include <date/date.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <cstdio>
|
||||
#include <displayapp/Colors.h>
|
||||
|
@ -448,20 +447,13 @@ void WatchFacePineTimeStyle::Refresh() {
|
|||
|
||||
currentDateTime = dateTimeController.CurrentDateTime();
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
auto newDateTime = currentDateTime.Get();
|
||||
|
||||
auto dp = date::floor<date::days>(newDateTime);
|
||||
auto time = date::make_time(newDateTime - dp);
|
||||
auto yearMonthDay = date::year_month_day(dp);
|
||||
|
||||
auto year = static_cast<int>(yearMonthDay.year());
|
||||
auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
|
||||
auto day = static_cast<unsigned>(yearMonthDay.day());
|
||||
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
|
||||
|
||||
uint8_t hour = time.hours().count();
|
||||
uint8_t minute = time.minutes().count();
|
||||
uint8_t second = time.seconds().count();
|
||||
auto hour = dateTimeController.Hours();
|
||||
auto minute = dateTimeController.Minutes();
|
||||
auto second = dateTimeController.Seconds();
|
||||
auto year = dateTimeController.Year();
|
||||
auto month = dateTimeController.Month();
|
||||
auto dayOfWeek = dateTimeController.DayOfWeek();
|
||||
auto day = dateTimeController.Day();
|
||||
|
||||
if (displayedHour != hour || displayedMinute != minute) {
|
||||
displayedHour = hour;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include <date/date.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include "displayapp/screens/WatchFaceTerminal.h"
|
||||
#include "displayapp/screens/BatteryIcon.h"
|
||||
|
@ -108,20 +107,13 @@ void WatchFaceTerminal::Refresh() {
|
|||
currentDateTime = dateTimeController.CurrentDateTime();
|
||||
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
auto newDateTime = currentDateTime.Get();
|
||||
|
||||
auto dp = date::floor<date::days>(newDateTime);
|
||||
auto time = date::make_time(newDateTime - dp);
|
||||
auto yearMonthDay = date::year_month_day(dp);
|
||||
|
||||
auto year = static_cast<int>(yearMonthDay.year());
|
||||
auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
|
||||
auto day = static_cast<unsigned>(yearMonthDay.day());
|
||||
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
|
||||
|
||||
uint8_t hour = time.hours().count();
|
||||
uint8_t minute = time.minutes().count();
|
||||
uint8_t second = time.seconds().count();
|
||||
auto hour = dateTimeController.Hours();
|
||||
auto minute = dateTimeController.Minutes();
|
||||
auto second = dateTimeController.Seconds();
|
||||
auto year = dateTimeController.Year();
|
||||
auto month = dateTimeController.Month();
|
||||
auto dayOfWeek = dateTimeController.DayOfWeek();
|
||||
auto day = dateTimeController.Day();
|
||||
|
||||
if (displayedHour != hour || displayedMinute != minute || displayedSecond != second) {
|
||||
displayedHour = hour;
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 9502bc27a3b32fa5759ea82a76c22551620ebcd2
|
Loading…
Reference in New Issue
Block a user