diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-27 18:34:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-27 18:34:03 +0000 |
commit | 6bef99aa7b2f30c0b5031c668b9ecea3e1171eea (patch) | |
tree | 238cc5b245e8a751100666e5972016c87b791768 | |
parent | 664c08f55700c7bbe99c9d8d85d384fde8764ee9 (diff) | |
download | gnunet-gtk-6bef99aa7b2f30c0b5031c668b9ecea3e1171eea.tar.gz gnunet-gtk-6bef99aa7b2f30c0b5031c668b9ecea3e1171eea.zip |
use new fs time apis
-rw-r--r-- | src/common.c | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/src/common.c b/src/common.c index 844dafdf..55dbc0f9 100644 --- a/src/common.c +++ b/src/common.c | |||
@@ -75,24 +75,10 @@ GNUNET_GTK_get_expiration_time (GtkSpinButton *spin) | |||
75 | { | 75 | { |
76 | struct GNUNET_TIME_Absolute ret; | 76 | struct GNUNET_TIME_Absolute ret; |
77 | int year; | 77 | int year; |
78 | time_t tp; | ||
79 | struct tm t; | ||
80 | 78 | ||
81 | year = gtk_spin_button_get_value_as_int (spin); | 79 | year = gtk_spin_button_get_value_as_int (spin); |
82 | memset (&t, 0, sizeof (t)); | 80 | GNUNET_assert (year >= 0); |
83 | if (year < 1900) | 81 | ret = GNUNET_FS_year_to_time ( (unsigned int) year); |
84 | { | ||
85 | GNUNET_break (0); | ||
86 | return GNUNET_TIME_absolute_get (); /* now */ | ||
87 | } | ||
88 | t.tm_year = year - 1900; | ||
89 | t.tm_mday = 1; | ||
90 | t.tm_mon = 1; | ||
91 | t.tm_wday = 1; | ||
92 | t.tm_yday = 1; | ||
93 | tp = mktime (&t); | ||
94 | GNUNET_break (tp != (time_t) -1); | ||
95 | ret.abs_value = tp * 1000LL; /* seconds to ms */ | ||
96 | GNUNET_break (GNUNET_TIME_absolute_get ().abs_value < ret.abs_value); | 82 | GNUNET_break (GNUNET_TIME_absolute_get ().abs_value < ret.abs_value); |
97 | return ret; | 83 | return ret; |
98 | } | 84 | } |
@@ -102,16 +88,9 @@ void | |||
102 | GNUNET_GTK_setup_expiration_year_adjustment (GtkBuilder *builder) | 88 | GNUNET_GTK_setup_expiration_year_adjustment (GtkBuilder *builder) |
103 | { | 89 | { |
104 | GtkAdjustment *aj; | 90 | GtkAdjustment *aj; |
105 | struct tm *t; | 91 | unsigned int year; |
106 | int year; | 92 | |
107 | time_t tp; | 93 | year = GNUNET_FS_get_current_year (); |
108 | |||
109 | tp = time (NULL); | ||
110 | t = gmtime (&tp); | ||
111 | if (t == NULL) | ||
112 | year = 0; | ||
113 | else | ||
114 | year = t->tm_year + 1900; | ||
115 | aj = GTK_ADJUSTMENT (gtk_builder_get_object (builder, | 94 | aj = GTK_ADJUSTMENT (gtk_builder_get_object (builder, |
116 | "expiration_year_adjustment")); | 95 | "expiration_year_adjustment")); |
117 | gtk_adjustment_set_value (aj, year + 2); | 96 | gtk_adjustment_set_value (aj, year + 2); |