-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimedate.h
More file actions
66 lines (54 loc) · 1.34 KB
/
timedate.h
File metadata and controls
66 lines (54 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef TIME_USER_H
#define TIME_USER_H
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
typedef enum {
SEC = 1,
MIN,
HOUR,
DAY,
MONTH,
YEAR
} eTIMEDATE;
typedef struct {
int8_t sec;
int8_t min;
int8_t hour;
} sTIME;
typedef struct {
int8_t year;
int8_t month;
int8_t day;
} sDATE;
typedef struct {
sTIME time;
sDATE date;
} sTIMEDATE;
typedef struct {
int8_t hour;
int8_t min;
uint8_t isRepeat;
uint8_t repeatDay;
uint8_t en;
} sALARM;
typedef struct {
uint16_t secF;
uint16_t minF;
uint16_t hourF;
} sTIMEFIELD;
void timeSet(sTIME* time, eTIMEDATE mark, int8_t value);
void timeInit(sTIME* time);
eTIMEDATE timeIncSec(sTIME* time);
int16_t timeCompare(sTIME* time1, sTIME* time2);
int16_t getWeekday(int8_t year, int8_t month, int8_t day);
int16_t getDaysFormOneMonth(int16_t year, int16_t month);
void dateInc(sDATE* date, uint8_t s);
void dateDec(sDATE* date, uint8_t s);
void dateFix(sDATE* date);
uint32_t unix_timestamp(uint8_t sec, uint8_t min, uint8_t hrs, uint8_t day, uint8_t mon, uint16_t year);
sTIMEDATE* unix2YMDHMS(uint32_t unix_time);
void utc2local(sTIME* utc_time, sDATE* utc_date, sTIME* timezone, sTIME* local_time, sDATE* local_date);
void local2utc(sTIME* utc_time, sDATE* utc_date, sTIME* timezone, sTIME* local_time, sDATE* local_date);
bool isTimeBetween(sTIME now, sTIME start, sTIME end);
#endif