From 3d67ad3a8aae85a41cfb18aadb430b8d088ed19b Mon Sep 17 00:00:00 2001 From: Christian Mehlis Date: Wed, 18 Dec 2013 20:47:33 +0100 Subject: [PATCH] add vtimer_get_localtime --- sys/include/vtimer.h | 8 ++++++++ sys/vtimer/vtimer.c | 12 ++++++++++++ 2 files changed, 20 insertions(+) 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 7fe4867d09..4086f4858f 100644 --- a/sys/vtimer/vtimer.c +++ b/sys/vtimer/vtimer.c @@ -259,6 +259,18 @@ void vtimer_now(timex_t *out) memcpy(out, &t, sizeof(timex_t)); } +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");