Merge pull request #442 from mehlis/vtimer_get_localtime

Vtimer get localtime
This commit is contained in:
Oleg Hahm 2014-01-15 09:19:06 -08:00
commit ed8a220cd0
2 changed files with 20 additions and 0 deletions

View File

@ -18,6 +18,8 @@
#ifndef __VTIMER_H
#define __VTIMER_H
#include <time.h>
#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.
*

View File

@ -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");