Loading...
Searching...
No Matches
datetime.h
1#pragma once
2
3#include <stdint.h>
4#include <stdbool.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10typedef struct {
11 // Time
12 uint8_t hour;
13 uint8_t minute;
14 uint8_t second;
15 // Date
16 uint8_t day;
17 uint8_t month;
18 uint16_t year;
19 uint8_t weekday;
20} DateTime;
21
28bool datetime_validate_datetime(DateTime* datetime);
29
38uint32_t datetime_datetime_to_timestamp(DateTime* datetime);
39
47void datetime_timestamp_to_datetime(uint32_t timestamp, DateTime* datetime);
48
55uint16_t datetime_get_days_per_year(uint16_t year);
56
63bool datetime_is_leap_year(uint16_t year);
64
71uint8_t datetime_get_days_per_month(bool leap_year, uint8_t month);
72
73#ifdef __cplusplus
74}
75#endif
Definition datetime.h:10
uint16_t year
Current year: 2000-2099.
Definition datetime.h:18
uint8_t day
Current day: 1-31.
Definition datetime.h:16
uint8_t minute
Minute: 0-59.
Definition datetime.h:13
uint8_t month
Current month: 1-12.
Definition datetime.h:17
uint8_t hour
Hour in 24H format: 0-23.
Definition datetime.h:12
uint8_t weekday
Current weekday: 1-7.
Definition datetime.h:19
uint8_t second
Second: 0-59.
Definition datetime.h:14