mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add gnc_parse_time_to_timet, a concatenation of strptime and mktime.
This will be needed for the price quotes on systems that lack a guile function `strptime'. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16016 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -107,3 +107,5 @@ Process *gnc_spawn_process_async(GList *argl, const gboolean search_path);
|
|||||||
|
|
||||||
gint gnc_process_get_fd(const Process *proc, const guint std_fd);
|
gint gnc_process_get_fd(const Process *proc, const guint std_fd);
|
||||||
void gnc_detach_process(Process *proc, const gboolean kill_it);
|
void gnc_detach_process(Process *proc, const gboolean kill_it);
|
||||||
|
|
||||||
|
time_t gnc_parse_time_to_timet(const gchar *s, const gchar *format);
|
||||||
|
|||||||
@@ -29,6 +29,9 @@
|
|||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HAVE_STRPTIME
|
||||||
|
# include "strptime.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "qof.h"
|
#include "qof.h"
|
||||||
#include "engine-helpers.h"
|
#include "engine-helpers.h"
|
||||||
@@ -1292,3 +1295,17 @@ gnc_detach_process (Process *proc, const gboolean kill_it)
|
|||||||
else
|
else
|
||||||
g_free (proc);
|
g_free (proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
time_t
|
||||||
|
gnc_parse_time_to_timet(const gchar *s, const gchar *format)
|
||||||
|
{
|
||||||
|
struct tm tm;
|
||||||
|
|
||||||
|
g_return_val_if_fail(s && format, -1);
|
||||||
|
|
||||||
|
if (!strptime(s, format, &tm))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return mktime(&tm);
|
||||||
|
}
|
||||||
|
|||||||
@@ -140,3 +140,13 @@ gint gnc_process_get_fd(const Process *proc, const gint std_fd);
|
|||||||
void gnc_detach_process(Process *proc, const gboolean kill_it);
|
void gnc_detach_process(Process *proc, const gboolean kill_it);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** Convert a time string to calendar time representation. Combine strptime and
|
||||||
|
* mktime into a single function to avoid the need to wrap struct tm *.
|
||||||
|
*
|
||||||
|
* @param s String representation of time.
|
||||||
|
*
|
||||||
|
* @param format Format specification.
|
||||||
|
*
|
||||||
|
* @return The time in seconds since unix epoch, or -1 on error */
|
||||||
|
time_t gnc_parse_time_to_timet(const gchar *s, const gchar *format);
|
||||||
|
|||||||
Reference in New Issue
Block a user