-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathdate_and_time.cpp
More file actions
48 lines (31 loc) · 1.34 KB
/
date_and_time.cpp
File metadata and controls
48 lines (31 loc) · 1.34 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
37
38
39
40
41
42
43
44
45
46
47
//=====[Libraries]=============================================================
#include "mbed.h"
#include "date_and_time.h"
//=====[Declaration of private defines]========================================
//=====[Declaration of private data types]=====================================
//=====[Declaration and initialization of public global objects]===============
//=====[Declaration of external public global variables]=======================
//=====[Declaration and initialization of public global variables]=============
//=====[Declaration and initialization of private global variables]============
//=====[Declarations (prototypes) of private functions]========================
//=====[Implementations of public functions]===================================
char* dateAndTimeRead()
{
time_t epochSeconds;
epochSeconds = time(NULL);
return ctime(&epochSeconds);
}
void dateAndTimeWrite( int year, int month, int day,
int hour, int minute, int second )
{
struct tm rtcTime;
rtcTime.tm_year = year - 1900;
rtcTime.tm_mon = month - 1;
rtcTime.tm_mday = day;
rtcTime.tm_hour = hour;
rtcTime.tm_min = minute;
rtcTime.tm_sec = second;
rtcTime.tm_isdst = -1;
set_time( mktime( &rtcTime ) );
}
//=====[Implementations of private functions]==================================