diff options
Diffstat (limited to 'include/posthaste/date.h')
-rw-r--r-- | include/posthaste/date.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/posthaste/date.h b/include/posthaste/date.h new file mode 100644 index 0000000..d091d79 --- /dev/null +++ b/include/posthaste/date.h @@ -0,0 +1,23 @@ +#ifndef DATE_H +#define DATE_H + +/* stuff related to posthaste date handling */ + +#include <stdint.h> +#include <time.h> +#include <stdbool.h> + +/* store dates as regular integers, with lowest five bits being the day, the + * next four the month, and the rest the year */ +typedef uint64_t ph_date_t; + +ph_date_t date_from_string(const char str[static 11]); +ph_date_t date_from_numbers(unsigned year, unsigned month, unsigned day); +void date_to_string(char str[static 11], ph_date_t date); +void date_split(ph_date_t date, unsigned *year, unsigned *month, unsigned *day); +bool date_valid(ph_date_t date); +struct tm tm_from_date(ph_date_t date); +ph_date_t date_from_tm(struct tm time); +ph_date_t current_date(); + +#endif /* DATE_H */ |