forked from enlightenment/efl
move eina_value_util_time_string_new() to not inline
uses strptime which will cause warnings for people who don't do includes correctly
This commit is contained in:
parent
5375e154fe
commit
3dd8fb8a55
|
@ -20,10 +20,6 @@
|
|||
#ifndef EINA_INLINE_VALUE_UTIL_X_
|
||||
#define EINA_INLINE_VALUE_UTIL_X_
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
@ -162,26 +158,6 @@ eina_value_util_time_new(time_t t)
|
|||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create a new #Eina_Value containing the passed parameter
|
||||
* @param timestr The value to use
|
||||
* @return The #Eina_Value
|
||||
* @since 1.12
|
||||
*/
|
||||
static inline Eina_Value *
|
||||
eina_value_util_time_string_new(const char *timestr)
|
||||
{
|
||||
Eina_Value *v;
|
||||
struct tm tm;
|
||||
time_t t;
|
||||
|
||||
if (!strptime(timestr, "%Y%m%dT%H:%M:%S", &tm)) return NULL;
|
||||
t = mktime(&tm);
|
||||
v = eina_value_new(EINA_VALUE_TYPE_TIMESTAMP);
|
||||
if (v) eina_value_set(v, t);
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create a new #Eina_Value containing the passed parameter
|
||||
* @param val The value to use
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "eina_safety_checks.h"
|
||||
#include "eina_value.h"
|
||||
#include "eina_stringshare.h"
|
||||
#include <time.h>
|
||||
|
||||
|
||||
typedef struct _Eina_Value_Util_Struct_Desc
|
||||
|
@ -78,3 +79,17 @@ eina_value_util_struct_desc_new(void)
|
|||
st_desc->base.ops = &operations;
|
||||
return (Eina_Value_Struct_Desc*)st_desc;
|
||||
}
|
||||
|
||||
EAPI Eina_Value *
|
||||
eina_value_util_time_string_new(const char *timestr)
|
||||
{
|
||||
Eina_Value *v;
|
||||
struct tm tm;
|
||||
time_t t;
|
||||
|
||||
if (!strptime(timestr, "%Y%m%dT%H:%M:%S", &tm)) return NULL;
|
||||
t = mktime(&tm);
|
||||
v = eina_value_new(EINA_VALUE_TYPE_TIMESTAMP);
|
||||
if (v) eina_value_set(v, t);
|
||||
return v;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,14 @@
|
|||
*/
|
||||
EAPI Eina_Value_Struct_Desc *eina_value_util_struct_desc_new(void);
|
||||
|
||||
/**
|
||||
* @brief Create a new #Eina_Value containing the passed parameter
|
||||
* @param timestr The value to use
|
||||
* @return The #Eina_Value
|
||||
* @since 1.12
|
||||
*/
|
||||
EAPI Eina_Value *eina_value_util_time_string_new(const char *timestr);
|
||||
|
||||
#include "eina_inline_value_util.x"
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue