aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-history.c
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <diegoe@svn.gnome.org>2007-01-03 16:18:47 +0800
committerDiego Escalante Urrelo <diegoe@src.gnome.org>2007-01-03 16:18:47 +0800
commit3442e0b90e66938881c2205c1bfd26e343ade466 (patch)
tree521e879ebbc0ef917b88abc2c59b262f6ac49ed1 /embed/ephy-history.c
parent1783853f31349da7285a26107d2525e809cdaa8e (diff)
downloadgsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar.gz
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar.bz2
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar.lz
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar.xz
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar.zst
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.zip
Avoid use of localtime by computing expiry in seconds instead of days.
2007-01-03 Diego Escalante Urrelo <diegoe@svn.gnome.org> * embed/ephy-favicon-cache.c: (icon_is_obsolete), (remove_obsolete_icons): * embed/ephy-history.c: (page_is_obsolete), (remove_obsolete_pages): Avoid use of localtime by computing expiry in seconds instead of days. Patch by Chris Wilson. svn path=/trunk/; revision=6786
Diffstat (limited to 'embed/ephy-history.c')
-rw-r--r--embed/ephy-history.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/embed/ephy-history.c b/embed/ephy-history.c
index 4b2876665..3d6e9897c 100644
--- a/embed/ephy-history.c
+++ b/embed/ephy-history.c
@@ -45,6 +45,9 @@
/* if you change this remember to change also the user interface description */
#define HISTORY_PAGE_OBSOLETE_DAYS 10
+/* the number of seconds in a day */
+#define SECS_PER_DAY (60*60*24)
+
#define EPHY_HISTORY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_HISTORY, EphyHistoryPrivate))
struct _EphyHistoryPrivate
@@ -240,23 +243,13 @@ ephy_history_class_init (EphyHistoryClass *klass)
}
static gboolean
-page_is_obsolete (EphyNode *node, GDate *now)
+page_is_obsolete (EphyNode *node, time_t now)
{
int last_visit;
- GDate date;
last_visit = ephy_node_get_property_int
(node, EPHY_NODE_PAGE_PROP_LAST_VISIT);
-
- g_date_clear (&date, 1);
-#if GLIB_CHECK_VERSION (2,9,0)
- g_date_set_time_t (&date, last_visit);
-#else
- g_date_set_time (&date, last_visit);
-#endif
-
- return (g_date_days_between (&date, now) >=
- HISTORY_PAGE_OBSOLETE_DAYS);
+ return now - last_visit >= HISTORY_PAGE_OBSOLETE_DAYS*SECS_PER_DAY;
}
static void
@@ -264,16 +257,9 @@ remove_obsolete_pages (EphyHistory *eb)
{
GPtrArray *children;
int i;
- GTime now;
- GDate current_date;
+ time_t now;
now = time (NULL);
- g_date_clear (&current_date, 1);
-#if GLIB_CHECK_VERSION (2,9,0)
- g_date_set_time_t (&current_date, time (NULL));
-#else
- g_date_set_time (&current_date, time (NULL));
-#endif
children = ephy_node_get_children (eb->priv->pages);
for (i = (int) children->len - 1; i >= 0; i--)
@@ -282,7 +268,7 @@ remove_obsolete_pages (EphyHistory *eb)
kid = g_ptr_array_index (children, i);
- if (page_is_obsolete (kid, &current_date))
+ if (page_is_obsolete (kid, now))
{
ephy_node_unref (kid);
}