format check in time lib

pull/293/head
Peter Buchegger 2023-05-17 21:34:41 +02:00
rodzic 74e01a76a7
commit a0ce4608ae
4 zmienionych plików z 322 dodań i 330 usunięć

Wyświetl plik

@ -47,7 +47,7 @@ jobs:
- 'lib/NTPClient'
- 'lib/PowerManagement'
- 'lib/System'
#- 'lib/TimeLib'
- 'lib/TimeLib'
steps:
- name: Checkout code
uses: actions/checkout@v3

Wyświetl plik

@ -135,13 +135,11 @@ int year(time_t t) { // the year for the given time
return tmYearToCalendar(tm.Year);
}
const String timeString()
{
const String timeString() {
return timeString(now());
}
const String timeString(time_t t)
{
const String timeString(time_t t) {
char line[30];
sprintf(line, "%02d:%02d:%02d", hour(t), minute(t), second(t));
return String(line);
@ -254,7 +252,6 @@ getExternalTime getTimePtr; // pointer to external sync function
time_t sysUnsyncedTime = 0; // the time sysTime unadjusted by sync
#endif
time_t now() {
// calculate number of seconds passed since last call to now()
while (millis() - prevMillis >= 1000) {

Wyświetl plik

@ -10,18 +10,35 @@
#ifndef _Time_h
#define _Time_h
#include <inttypes.h>
#include <Arduino.h>
#include <inttypes.h>
typedef enum {timeNotSet, timeNeedsSync, timeSet
typedef enum {
timeNotSet,
timeNeedsSync,
timeSet
} timeStatus_t;
typedef enum {
dowInvalid, dowSunday, dowMonday, dowTuesday, dowWednesday, dowThursday, dowFriday, dowSaturday
dowInvalid,
dowSunday,
dowMonday,
dowTuesday,
dowWednesday,
dowThursday,
dowFriday,
dowSaturday
} timeDayOfWeek_t;
typedef enum {
tmSecond, tmMinute, tmHour, tmWday, tmDay,tmMonth, tmYear, tmNbrFields
tmSecond,
tmMinute,
tmHour,
tmWday,
tmDay,
tmMonth,
tmYear,
tmNbrFields
} tmByteFields;
typedef struct {
@ -43,7 +60,6 @@ typedef struct {
typedef time_t (*getExternalTime)();
// typedef void (*setExternalTime)(const time_t); // not used in this version
/*==============================================================================*/
/* Useful Constants */
#define SECS_PER_MIN ((time_t)(60UL))
@ -69,7 +85,6 @@ typedef time_t(*getExternalTime)();
#define previousSunday(_time_) ((_time_)-elapsedSecsThisWeek(_time_)) // time at the start of the week for the given time
#define nextSunday(_time_) (previousSunday(_time_) + SECS_PER_WEEK) // time at the end of the week for the given time
/* Useful Macros for converting elapsed time to a time_t */
#define minutesToTime_t(M) ((M)*SECS_PER_MIN)
#define hoursToTime_t(H) ((H)*SECS_PER_HOUR)
@ -124,4 +139,3 @@ void breakTime(time_t time, tmElements_t &tm); // break time_t into elements
time_t makeTime(const tmElements_t &tm); // convert time elements into time_t
#endif /* _Time_h */

Wyświetl plik

@ -9,48 +9,29 @@
*
*/
#include <Arduino.h>
#include "TimeLib.h"
#include <Arduino.h>
const String monthNames[] =
{
"Error", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
};
const String monthNames[] = {"Error", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
const String monthStr(uint8_t month)
{
const String monthStr(uint8_t month) {
return monthNames[month];
}
const String monthShortNames[] = {"Err", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
const String monthShortNames[] =
{
"Err", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
const String monthShortStr(uint8_t month)
{
const String monthShortStr(uint8_t month) {
return monthShortNames[month];
}
const String dayNames[] = {"Err", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const String dayNames[] =
{
"Err", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
};
const String dayStr(uint8_t day)
{
const String dayStr(uint8_t day) {
return dayNames[day];
}
const String dayShortNames[] = {"Err", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
const String dayShortNames[] =
{
"Err", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
const String dayShortStr(uint8_t day)
{
const String dayShortStr(uint8_t day) {
return dayShortNames[day];
}