[libgdata/libgdata-0-5: 2/8] Bug 598910 — Timestamp bug
- From: Philip Withnall <pwithnall src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgdata/libgdata-0-5: 2/8] Bug 598910 — Timestamp bug
- Date: Sun, 22 Nov 2009 16:51:28 +0000 (UTC)
commit f65b0d71ec208c5fb9e6f5b4521fc3ecef78e024
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Oct 19 16:53:57 2009 +0100
Bug 598910 â?? Timestamp bug
Fixes incorrect usage of GTimeVal.tv_usec as milliseconds in the
PicasaWeb backend and in GDataGDWhen. Closes: bgo#598910.
gdata/gd/gdata-gd-when.c | 15 ++++++++++-----
gdata/services/picasaweb/gdata-picasaweb-album.c | 2 +-
gdata/services/picasaweb/gdata-picasaweb-file.c | 4 +---
3 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-when.c b/gdata/gd/gdata-gd-when.c
index 04066e5..aec3337 100644
--- a/gdata/gd/gdata-gd-when.c
+++ b/gdata/gd/gdata-gd-when.c
@@ -404,6 +404,8 @@ gdata_gd_when_new (GTimeVal *start_time, GTimeVal *end_time, gboolean is_date)
gint
gdata_gd_when_compare (const GDataGDWhen *a, const GDataGDWhen *b)
{
+ gint64 start_diff, end_diff;
+
if (a == NULL && b != NULL)
return -1;
else if (b == NULL)
@@ -414,11 +416,14 @@ gdata_gd_when_compare (const GDataGDWhen *a, const GDataGDWhen *b)
if (a->priv->is_date != b->priv->is_date)
return CLAMP (b->priv->is_date - a->priv->is_date, -1, 1);
- if (a->priv->start_time.tv_sec == b->priv->start_time.tv_sec && a->priv->start_time.tv_usec == b->priv->start_time.tv_usec)
- return CLAMP ((b->priv->end_time.tv_sec * 1000 + b->priv->end_time.tv_usec) -
- (a->priv->end_time.tv_sec * 1000 + a->priv->end_time.tv_usec), -1, 1);
- return CLAMP ((b->priv->start_time.tv_sec * 1000 + b->priv->start_time.tv_usec) -
- (a->priv->start_time.tv_sec * 1000 + a->priv->start_time.tv_usec), -1, 1);
+ start_diff = (b->priv->start_time.tv_sec - a->priv->start_time.tv_sec) * 1000000 +
+ (b->priv->start_time.tv_usec - a->priv->start_time.tv_usec);
+ end_diff = (b->priv->end_time.tv_sec - a->priv->end_time.tv_sec) * 1000000 +
+ (b->priv->end_time.tv_usec - a->priv->end_time.tv_usec);
+
+ if (start_diff == 0)
+ return CLAMP (end_diff, -1, 1);
+ return CLAMP (start_diff, -1, 1);
}
/**
diff --git a/gdata/services/picasaweb/gdata-picasaweb-album.c b/gdata/services/picasaweb/gdata-picasaweb-album.c
index e257e39..464a1ee 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-album.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-album.c
@@ -737,7 +737,7 @@ get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->timestamp.tv_sec != 0 || priv->timestamp.tv_usec != 0) {
/* in milliseconds */
g_string_append_printf (xml_string, "<gphoto:timestamp>%" G_GUINT64_FORMAT "</gphoto:timestamp>",
- (guint64) (priv->timestamp.tv_sec * 1000 + priv->timestamp.tv_usec));
+ ((guint64) priv->timestamp.tv_sec) * 1000 + priv->timestamp.tv_usec / 1000);
}
if (priv->is_commenting_enabled == FALSE)
diff --git a/gdata/services/picasaweb/gdata-picasaweb-file.c b/gdata/services/picasaweb/gdata-picasaweb-file.c
index cc50998..06998b3 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-file.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-file.c
@@ -947,9 +947,7 @@ get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->timestamp.tv_sec != 0 || priv->timestamp.tv_usec != 0) {
/* timestamp is in milliseconds */
g_string_append_printf (xml_string, "<gphoto:timestamp>%" G_GUINT64_FORMAT "</gphoto:timestamp>",
- (guint64) (priv->timestamp.tv_sec * 1000 + priv->timestamp.tv_usec));
- /* RHSTODO: test that different timestamps are being set in this XML correctly and are
- in fact just being ignored by Google */
+ ((guint64) priv->timestamp.tv_sec) * 1000 + priv->timestamp.tv_usec / 1000);
}
if (priv->is_commenting_enabled == TRUE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]