#include <time.h>

#ifndef CLOCK_H_
    #define CLOCK_H_

    typedef struct {
        u32 end;            // real end time
        u16 read, write;    // read write caches
    } ClockTimer;

    typedef struct {
        ClockTimer t1, t2, t3, t4;  // timers
        u32 start;                  // uptime offset
    } ClockDevice;

    #define   YEAR(tm) (tm->tm_year - 100)
    #define  MONTH(tm) (tm->tm_mon)
    #define    DAY(tm) (tm->tm_mday - 1)
    #define   HOUR(tm) (tm->tm_hour)
    #define MINUTE(tm) (tm->tm_min)
    #define SECOND(tm) (tm->tm_sec)

    u32 get_uptime(void);
    void uptime_handler(void);
    void init_clock(void);
    struct tm* get_datetime(void);

    bool check_timers(ClockDevice *clk);

    u8 get_timer_high(ClockTimer *t);
    u8 get_timer_low( ClockTimer *t);
    void set_timer_high(ClockTimer *t, u8 high);
    void set_timer_low( ClockTimer *t, u8  low);

#endif