2016-02-18 09:55:07 +01:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* Resource for timezone handling
|
|
|
|
* \author
|
|
|
|
* Ralf Schlatterbeck <rsc@runtux.com>
|
|
|
|
*
|
|
|
|
* \brief get/put timezone string
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "contiki.h"
|
2016-03-29 17:47:03 +02:00
|
|
|
#include "xtime.h"
|
2016-02-18 09:55:07 +01:00
|
|
|
#include "time_resource.h"
|
|
|
|
#include "jsonparse.h"
|
|
|
|
#include "er-coap.h"
|
|
|
|
#include "generic_resource.h"
|
|
|
|
|
2017-08-20 15:01:30 +02:00
|
|
|
int timezone_from_string
|
|
|
|
(const char *name, const char *uri, const char *query, const char *s)
|
2016-02-18 09:55:07 +01:00
|
|
|
{
|
|
|
|
set_tz (s);
|
2016-02-26 07:54:05 +01:00
|
|
|
return 0;
|
2016-02-18 09:55:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
2017-08-20 15:01:30 +02:00
|
|
|
timezone_to_string
|
|
|
|
( const char *name
|
|
|
|
, const char *uri
|
|
|
|
, const char *query
|
|
|
|
, char *buf
|
|
|
|
, size_t bsize
|
|
|
|
)
|
2016-02-18 09:55:07 +01:00
|
|
|
{
|
|
|
|
if (get_tz (buf, bsize) == NULL) {
|
|
|
|
*buf = '\0';
|
|
|
|
}
|
|
|
|
return strlen (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
GENERIC_RESOURCE
|
|
|
|
( timezone
|
|
|
|
, TZ
|
|
|
|
, s
|
2016-02-26 07:54:05 +01:00
|
|
|
, 1
|
2016-02-18 09:55:07 +01:00
|
|
|
, timezone_from_string
|
|
|
|
, timezone_to_string
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VI settings, see coding style
|
|
|
|
* ex:ts=8:et:sw=2
|
|
|
|
*/
|
|
|
|
|