2015-10-27 18:30:49 -04:00
|
|
|
/*
|
|
|
|
* Copyright 2015 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#ifndef OCARINA_CORE_DATE_H
|
|
|
|
#define OCARINA_CORE_DATE_H
|
|
|
|
|
2015-10-28 03:31:09 -04:00
|
|
|
#include <core/file.h>
|
2016-07-26 16:20:04 -04:00
|
|
|
#include <stdint.h>
|
2015-10-28 03:31:09 -04:00
|
|
|
|
|
|
|
|
2015-10-27 18:30:49 -04:00
|
|
|
struct date {
|
2016-07-26 16:20:04 -04:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint16_t d_year;
|
|
|
|
uint8_t d_month;
|
|
|
|
uint8_t d_day;
|
|
|
|
};
|
|
|
|
uint32_t d_stamp;
|
|
|
|
};
|
2015-10-27 18:30:49 -04:00
|
|
|
};
|
|
|
|
|
2015-10-27 19:13:08 -04:00
|
|
|
|
2015-11-02 08:35:58 -05:00
|
|
|
/* Set the date structure. */
|
|
|
|
void date_set(struct date *, unsigned int, unsigned int, unsigned int);
|
|
|
|
|
2015-10-27 19:13:08 -04:00
|
|
|
/* Set the provided date structure to today's date. */
|
|
|
|
void date_today(struct date *);
|
|
|
|
|
2015-10-28 03:31:09 -04:00
|
|
|
/* Read the date from file. */
|
2018-02-16 13:30:23 -05:00
|
|
|
void date_read(struct file *, struct date *);
|
|
|
|
void date_read_stamp(struct file *, struct date *);
|
2015-10-28 03:31:09 -04:00
|
|
|
|
|
|
|
/* Write the date to file. */
|
2018-02-16 13:30:23 -05:00
|
|
|
void date_write(struct file *, struct date *);
|
|
|
|
void date_write_stamp(struct file *, struct date *);
|
2015-10-28 03:31:09 -04:00
|
|
|
|
2015-10-28 04:01:43 -04:00
|
|
|
/*
|
|
|
|
* Convert the date into a string.
|
|
|
|
* This function allocates a new string that MUST be freed with g_free().
|
|
|
|
*/
|
|
|
|
gchar *date_string(const struct date *);
|
|
|
|
|
2015-10-28 01:44:42 -04:00
|
|
|
/*
|
|
|
|
* Compare two dates.
|
|
|
|
*
|
|
|
|
* if ret < 0: lhs < rhs.
|
|
|
|
* if ret = 0: lhs == rhs.
|
|
|
|
* if ret > 0: lhs > rhs.
|
|
|
|
*/
|
|
|
|
int date_compare(const struct date *, const struct date *);
|
|
|
|
|
2015-10-27 18:30:49 -04:00
|
|
|
#endif /* OCARINA_CORE_DATE_H */
|