Merge pull request #442 from mehlis/vtimer_get_localtime
Vtimer get localtime
This commit is contained in:
commit
ed8a220cd0
@ -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.
|
||||
*
|
||||
|
||||
@ -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");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user