~kelemeng/indicator-datetime/bug845473

« back to all changes in this revision

Viewing changes to src/datetime-service.c

  • Committer: Ted Gould
  • Date: 2011-08-17 19:56:03 UTC
  • mfrom: (120.2.2 use_datetime)
  • Revision ID: ted@gould.cx-20110817195603-qtvdo2vc2sjnelwg
Use cleaner gdatetime

Show diffs side-by-side

added added

removed removed

Lines of Context:
299
299
static gboolean
300
300
update_datetime (gpointer user_data)
301
301
{
 
302
        GDateTime *datetime;
 
303
        gchar *utf8;
 
304
 
302
305
        g_debug("Updating Date/Time");
303
306
 
304
 
        gchar longstr[128];
305
 
        time_t t;
306
 
        struct tm *ltime;
307
 
 
308
 
        t = time(NULL);
309
 
        ltime = localtime(&t);
310
 
        if (ltime == NULL) {
 
307
        datetime = g_date_time_new_now_local ();
 
308
        if (datetime == NULL) {
311
309
                g_warning("Error getting local time");
312
310
                dbusmenu_menuitem_property_set(date, DBUSMENU_MENUITEM_PROP_LABEL, _("Error getting time"));
 
311
                g_date_time_unref (datetime);
313
312
                return FALSE;
314
313
        }
315
314
 
316
 
        /* Translators: strftime(3) style date format on top of the menu when you click on the clock */
317
 
        strftime(longstr, 128, _("%A, %e %B %Y"), ltime);
318
 
        
319
 
        gchar * utf8 = g_locale_to_utf8(longstr, -1, NULL, NULL, NULL);
 
315
        /* eranslators: strftime(3) style date format on top of the menu when you click on the clock */
 
316
        utf8 = g_date_time_format (datetime, _("%A, %e %B %Y"));
 
317
 
320
318
        dbusmenu_menuitem_property_set(date, DBUSMENU_MENUITEM_PROP_LABEL, utf8);
 
319
 
 
320
        g_date_time_unref (datetime);
321
321
        g_free(utf8);
322
322
 
323
323
        return FALSE;
701
701
 
702
702
        // Get today & work out query times
703
703
        time(&curtime);
704
 
        struct tm *today = localtime(&curtime);
 
704
        struct tm *today = localtime(&curtime);
705
705
        const int mday = today->tm_mday;
706
706
        const int mon = today->tm_mon;
707
707
        const int year = today->tm_year;