Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Removed usage of GDateTime.
Browse files Browse the repository at this point in the history
For compatibility with Ubuntu 10.04 LTS.
  • Loading branch information
vain committed Feb 27, 2012
1 parent 98db935 commit 9a354c7
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions pdfpres.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <time.h>

#include <gtk/gtk.h>
#include <gdk/gdk.h>
Expand Down Expand Up @@ -694,11 +695,23 @@ static void resetTimer()

static gboolean printCurrentTime(GtkWidget *timeElapsedLabel)
{
GDateTime *now = g_date_time_new_now_local();
gchar *nowFmt = g_date_time_format(now, "%R");
char nowFmt[6] = "";
time_t t;
struct tm *tmp;

t = time(NULL);
tmp = localtime(&t);
if (tmp == NULL)
{
perror("localtime");
return TRUE;
}
if (strftime(nowFmt, sizeof(nowFmt), "%R", tmp) == 0)
{
fprintf(stderr, "strftime failed: 0\n");
return TRUE;
}
gtk_label_set_text(GTK_LABEL(timeElapsedLabel), nowFmt);
g_free(nowFmt);
g_date_time_unref(now);

return TRUE;
}
Expand Down

0 comments on commit 9a354c7

Please sign in to comment.