diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-11-09 07:55:35 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-11-09 07:55:35 +0800 |
commit | e963dd81114ca2f531b9336ff4afe33de0ec8f5a (patch) | |
tree | d9d419cbde6abb2edfce32d707584e421c700a20 | |
parent | 7d0d2b3c3fe52cf5564c606cf7f0ad8382cba27a (diff) | |
download | gsoc2013-epiphany-e963dd81114ca2f531b9336ff4afe33de0ec8f5a.tar gsoc2013-epiphany-e963dd81114ca2f531b9336ff4afe33de0ec8f5a.tar.gz gsoc2013-epiphany-e963dd81114ca2f531b9336ff4afe33de0ec8f5a.tar.bz2 gsoc2013-epiphany-e963dd81114ca2f531b9336ff4afe33de0ec8f5a.tar.lz gsoc2013-epiphany-e963dd81114ca2f531b9336ff4afe33de0ec8f5a.tar.xz gsoc2013-epiphany-e963dd81114ca2f531b9336ff4afe33de0ec8f5a.tar.zst gsoc2013-epiphany-e963dd81114ca2f531b9336ff4afe33de0ec8f5a.zip |
Fix time filter for time zone != GMT.
2004-11-09 Christian Persch <chpe@cvs.gnome.org>
* src/ephy-history-window.c: (add_by_date_filter):
Fix time filter for time zone != GMT.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/ephy-history-window.c | 34 |
2 files changed, 29 insertions, 11 deletions
@@ -1,3 +1,9 @@ +2004-11-09 Christian Persch <chpe@cvs.gnome.org> + + * src/ephy-history-window.c: (add_by_date_filter): + + Fix time filter for time zone != GMT. + 2004-11-07 Christian Persch <chpe@cvs.gnome.org> * src/prefs-dialog.c: (language_editor_update_buttons): diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c index 0a0ed14d5..502dcbeb4 100644 --- a/src/ephy-history-window.c +++ b/src/ephy-history-window.c @@ -879,38 +879,50 @@ add_by_site_filter (EphyHistoryWindow *editor, EphyNodeFilter *filter, int level } #define SEC_PER_DAY (60 * 60 * 24) +#include "time.h" static void -add_by_date_filter (EphyHistoryWindow *editor, EphyNodeFilter *filter, int level, +add_by_date_filter (EphyHistoryWindow *editor, + EphyNodeFilter *filter, + int level, EphyNode *equals) { - GTime now, cmp_time, days; + time_t now, midnight, cmp_time = 0; + struct tm btime; int time_range; - /* FIXME this is probably wrong for timezones */ - time_range = gtk_combo_box_get_active (GTK_COMBO_BOX (editor->priv->time_combo)); + /* no need to setup a new filter */ + if (time_range == TIME_EVER) return; + now = time (NULL); - days = now / SEC_PER_DAY; + if (localtime_r (&now, &btime) == NULL) return; + + /* get start of day */ + btime.tm_sec = 0; + btime.tm_min = 0; + btime.tm_hour = 0; + midnight = mktime (&btime); + /* FIXME: take switches from/to DST into account! */ switch (time_range) { - case TIME_EVER: - return; case TIME_TODAY: + cmp_time = midnight; break; case TIME_LAST_TWO_DAYS: - days -= 1; + cmp_time = midnight - SEC_PER_DAY; break; case TIME_LAST_THREE_DAYS: - days -= 2; + cmp_time = midnight - 2 * SEC_PER_DAY; + break; + default: + g_return_if_reached (); break; } - cmp_time = days * SEC_PER_DAY; - ephy_node_filter_add_expression (filter, ephy_node_filter_expression_new (EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN, |