forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeHelper.h
More file actions
36 lines (23 loc) · 1.12 KB
/
Copy pathTimeHelper.h
File metadata and controls
36 lines (23 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// matth-x/ESP8266-OCPP
// Copyright Matthias Akstaller 2019 - 2021
// MIT License
#ifndef TIMEHELPER_H
#define TIMEHELPER_H
#include <TimeLib.h>
//Infinity begins in the end of year 2035
//... it is close to the "year 2038 problem" that occurs if signed longs were used for time_t but has some space
//left to prevent overflows if something is added to INFINITY
//As long as it is garantueed that time_t uses unsigned longs, CalendarYrToTm(2036) could be raised to CalenderYrToTm(2100)
#define INFINITY_THLD ((time_t) (((time_t) SECS_PER_YEAR) * ((time_t) CalendarYrToTm(2036))))
#define INFINITY_STRING "2036-01-01T00:00:00.000Z"
#define JSONDATE_LENGTH 24 //JSON Date
//#define JSONDATE_LENGTH 32 //ISO 8601
namespace ArduinoOcpp {
bool setTimeFromJsonDateString(const char* jsonDateString);
bool getJsonDateStringFromSystemTime(char* jsonDateString, int bufflength);
bool getJsonDateStringFromGivenTime(char* jsonDateString, int bufflength, time_t t);
bool getTimeFromJsonDateString(const char* jsonDateString, time_t *result);
time_t minimum(time_t t1, time_t t2);
void printTime(time_t t);
} //end namespace ArduinoOcpp
#endif