cairo_restore(cr);
}
+static struct tm *
+clock_get_time(void)
+{
+ time_t now; /* Current system time */
+
+ /* Get the current time */
+ now = time(NULL);
+
+ /* Format and print the time, "ddd yyyy-mm-dd hh:mm:ss zzz" */
+ return localtime(&now);
+}
+
static void
draw_clock_hands(GtkWidget *clock, cairo_t *cr)
{
double radius, length;
int hours, minutes, seconds;
double sin_x, cos_y;
- time_t now; /* Current system time */
struct tm *ts;
- /* Get the current time */
- now = time(NULL);
-
- /* Format and print the time, "ddd yyyy-mm-dd hh:mm:ss zzz" */
- ts = localtime(&now);
+ ts = clock_get_time();
center_x = clock->allocation.width / 2;
center_y = clock->allocation.height / 2;
char str[32];
double x, y;
cairo_text_extents_t extents;
- time_t now; /* Current system time */
struct tm *ts;
center_x = clock->allocation.width / 2;
cairo_set_font_size(cr, CALENDAR_FONTS_SIZE);
cairo_set_source_rgb(cr, 0, 0, 0);
- /* Get the current time */
- now = time(NULL);
-
- /* Format and print the time, "ddd yyyy-mm-dd hh:mm:ss zzz" */
- ts = localtime(&now);
+ ts = clock_get_time();
/* Weekday */
strftime(str, 256, "%A", ts);
/* Day of month */
cairo_set_font_size(cr, 30);
strftime(str, 256, "%d", ts);
+
+ fprintf(stderr, "TIME=[%s]\n", str);
+
+ if (str[0] == '0') {
+ /* Remove leading zero */
+ str[0] = str[1];
+ str[1] = '\0';
+ }
+
+ fprintf(stderr, "TIME=[%s]\n", str);
+
/* Get text dimensions */
cairo_text_extents(cr, str, &extents);
x = center_x - extents.width / 2;