-
Notifications
You must be signed in to change notification settings - Fork 10
/
CWDateTime.cpp
59 lines (47 loc) · 929 Bytes
/
CWDateTime.cpp
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
#include "CWDateTime.h"
void CWDateTime::begin()
{
myTZ.setCache(0);
waitForSync();
}
void CWDateTime::setTimezone(const char *timeZone)
{
myTZ.setCache(0);
myTZ.setLocation(timeZone);
waitForSync();
}
String CWDateTime::getTimezone()
{
return myTZ.getTimezoneName(0);
}
void CWDateTime::update()
{
}
String CWDateTime::getFormattedTime()
{
return myTZ.dateTime();
}
char *CWDateTime::getHour(const char *format)
{
static char buffer[3] = {'\0'};
snprintf(buffer, sizeof(buffer), format, myTZ.dateTime("H"));
return buffer;
}
char *CWDateTime::getMinute(const char *format)
{
static char buffer[3] = {'\0'};
strncpy(buffer, myTZ.dateTime("i").c_str(), sizeof(buffer));
return buffer;
}
int CWDateTime::getHour()
{
return myTZ.dateTime("h").toInt();
}
int CWDateTime::getMinute()
{
return myTZ.dateTime("i").toInt();
}
int CWDateTime::getSecond()
{
return myTZ.dateTime("s").toInt();
}