-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiotdate.h
69 lines (60 loc) · 1.58 KB
/
iotdate.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* The IoT Calendar Library for Arduino
*
* Written by Dan Cogliano - DanTheGeek.com
*
* The iotDate provides date routines for use with the IoT Calendar
* Service.
*
* More information is at iotcalendar.org
*/
#ifndef IOT_DATE_H
#define IOT_DATE_H
#include <time.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
//#include <HTTPClient.h>
#include <ESPHTTPClient.h>
#include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson
#include <NTPClient.h> //https://github.com/arduino-libraries/NTPClient
#include "iotcalendar.h"
#include "language_en.h"
class iotDate
{
public:
iotDate(long timeoffset);
iotDate(iotCalendar &iotc);
long getMonth(){return _month;};
long getDay(){return _day;};
long getWDay(){return _wday;};
long getYear(){return _year;};
long getHour(){return _hour;};
long getMinute(){return _minute;};
long getSecond(){return _second;};
long getTimeOffset(){return _timeoffset;};
time_t getTimeStamp(){return _timestamp;};
const char *getShortMonthString(int month);
const char *getMonthString(int month);
const char *getDOWString(int dow);
const char *getShortDOWString(int dow);
bool isLeapYear(int year);
bool isWeekend(int dow){return dow == 0 || dow == 6;};
bool isWeekday(int dow){return !(dow == 0 || dow == 6);};
int getDaysInMonth(int month, int year);
int getStringLength(char *str, int strlen = 0);
private:
time_t _timestamp;
long _timeoffset;
long _hour;
long _minute;
long _second;
long _month;
long _day;
long _wday;
long _year;
void initTime();
};
#endif