aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJörn Horstmann <launchpad@planetxml.de>2011-09-21 15:19:53 -0500
committerTed Gould <ted@gould.cx>2011-09-21 15:19:53 -0500
commitb1bbe3c1e2af12078d9a77d55e6f87a67b3f02c3 (patch)
treeb49f40c2e78de619ac923605141596487a76be9d /src
parent92cfa6c3050d0b66b7a3c3c508734f46a9d3b391 (diff)
downloadayatana-indicator-datetime-b1bbe3c1e2af12078d9a77d55e6f87a67b3f02c3.tar.gz
ayatana-indicator-datetime-b1bbe3c1e2af12078d9a77d55e6f87a67b3f02c3.tar.bz2
ayatana-indicator-datetime-b1bbe3c1e2af12078d9a77d55e6f87a67b3f02c3.zip
Use g_datetime() to measure string (6 LOC)
Diffstat (limited to 'src')
-rw-r--r--src/indicator-datetime.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 339ea2f..8e5f421 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -1092,12 +1092,14 @@ guess_label_size (IndicatorDatetime * self)
g_debug("Checking against %d possible times", timevals->len);
gint check_time;
for (check_time = 0; check_time < timevals->len; check_time++) {
- gchar longstr[256];
- strftime(longstr, 256, self->priv->time_string, &(g_array_index(timevals, struct tm, check_time)));
+ struct tm * timeval = &g_array_index(timevals, struct tm, check_time);
+ GDateTime * dt = g_date_time_new_local(timeval->tm_year, timeval->tm_mon, timeval->tm_mday, timeval->tm_hour, timeval->tm_min, timeval->tm_sec);
+ gchar * timestr = g_date_time_format(dt, self->priv->time_string);
- gchar * utf8 = g_locale_to_utf8(longstr, -1, NULL, NULL, NULL);
- gint length = measure_string(style, context, utf8);
- g_free(utf8);
+ gint length = measure_string(style, context, timestr);
+
+ g_free(timestr);
+ g_date_time_unref(dt);
if (length > *max_width) {
*max_width = length;