diff --git a/sys/include/vtimer.h b/sys/include/vtimer.h index 27e705b113..18e8228b7a 100644 --- a/sys/include/vtimer.h +++ b/sys/include/vtimer.h @@ -18,6 +18,8 @@ #ifndef __VTIMER_H #define __VTIMER_H +#include + #include "queue.h" #include "timex.h" #include "msg.h" @@ -45,6 +47,12 @@ typedef struct vtimer_t { */ void vtimer_now(timex_t *out); +/** + * @brief Returns the current time in broken down format + * @param[out] localt Pointer to structure to receive time + */ +void vtimer_get_localtime(struct tm *localt); + /** * @brief Initializes the vtimer subsystem. To be called once at system initialization. Will be initialized by auto_init. * diff --git a/sys/vtimer/vtimer.c b/sys/vtimer/vtimer.c index 9236974a54..8f9ee695b2 100644 --- a/sys/vtimer/vtimer.c +++ b/sys/vtimer/vtimer.c @@ -261,6 +261,18 @@ void vtimer_now(timex_t *out) out->microseconds = us % (1000 * 1000); } +void vtimer_get_localtime(struct tm *localt) +{ + timex_t now; + vtimer_now(&now); + + localt->tm_sec = now.seconds % 60; + localt->tm_min = (now.seconds / 60) % 60; + localt->tm_hour = (now.seconds / 60 / 60) % 24; + + // TODO: fill the other fields +} + int vtimer_init() { DEBUG("vtimer_init().\n");