summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2008-08-22 14:13:56 +0000
committerBastien Nocera <hadess@src.gnome.org>2008-08-22 14:13:56 +0000
commit599d68b3d3ac84897b4638b430b5eda8b0efb4c9 (patch)
treee025afcc279a81341c815b6407107ba8bbe02236
parentb4917ecbab1a44cdc8cb43d7a22d3748eba37e50 (diff)
downloadlibsoup-599d68b3d3ac84897b4638b430b5eda8b0efb4c9.tar.gz
Add a SoupDate to GTimeVal conversion function, for use in gvfs. #549006,
2008-08-22 Bastien Nocera <hadess@hadess.net> * libsoup/soup-date.c (soup_date_to_time_t), (soup_date_to_timeval): * libsoup/soup-date.h: Add a SoupDate to GTimeVal conversion function, for use in gvfs. #549006, with help from Dan Winship <danw@gnome.org> svn path=/trunk/; revision=1154
-rw-r--r--ChangeLog8
-rw-r--r--libsoup/soup-date.c22
-rw-r--r--libsoup/soup-date.h2
3 files changed, 30 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 36d81525..696f2bed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-08-22 Bastien Nocera <hadess@hadess.net>
+
+ * libsoup/soup-date.c (soup_date_to_time_t),
+ (soup_date_to_timeval):
+ * libsoup/soup-date.h: Add a SoupDate to GTimeVal conversion
+ function, for use in gvfs. #549006, with help from Dan Winship
+ <danw@gnome.org>
+
2008-08-18 Dan Winship <danw@gnome.org>
* libsoup.pc.in (Requires): Revert previous commit; that would
diff --git a/libsoup/soup-date.c b/libsoup/soup-date.c
index 4aa3c3b0..8d690eb4 100644
--- a/libsoup/soup-date.c
+++ b/libsoup/soup-date.c
@@ -542,6 +542,7 @@ time_t
soup_date_to_time_t (SoupDate *date)
{
time_t tt;
+ GTimeVal val;
/* FIXME: offset, etc */
@@ -557,8 +558,8 @@ soup_date_to_time_t (SoupDate *date)
if (sizeof (time_t) == 4 && date->year > 2038)
return (time_t)0x7fffffff;
- tt = rata_die_day (date) - TIME_T_EPOCH_RATA_DIE_DAY;
- tt = ((((tt * 24) + date->hour) * 60) + date->minute) * 60 + date->second;
+ soup_date_to_timeval (date, &val);
+ tt = val.tv_sec;
if (sizeof (time_t) == 4 && tt < 0)
return (time_t)0x7fffffff;
@@ -566,6 +567,23 @@ soup_date_to_time_t (SoupDate *date)
}
/**
+ * soup_date_to_timeval:
+ * @date: a #SoupDate
+ * @time: a #GTimeVal structure in which to store the converted time.
+ *
+ * Converts @date to a #GTimeVal.
+ */
+void
+soup_date_to_timeval (SoupDate *date, GTimeVal *time)
+{
+ /* FIXME: offset, etc */
+
+ time->tv_sec = rata_die_day (date) - TIME_T_EPOCH_RATA_DIE_DAY;
+ time->tv_sec = ((((time->tv_sec * 24) + date->hour) * 60) + date->minute) * 60 + date->second;
+ time->tv_usec = 0;
+}
+
+/**
* soup_date_is_past:
* @date: a #SoupDate
*
diff --git a/libsoup/soup-date.h b/libsoup/soup-date.h
index 043cd0ab..41f5db0a 100644
--- a/libsoup/soup-date.h
+++ b/libsoup/soup-date.h
@@ -51,6 +51,8 @@ SoupDate *soup_date_new_from_now (int offset_seconds);
char *soup_date_to_string (SoupDate *date,
SoupDateFormat format);
time_t soup_date_to_time_t (SoupDate *date);
+void soup_date_to_timeval (SoupDate *date,
+ GTimeVal *time);
gboolean soup_date_is_past (SoupDate *date);