From 6ff646f569bf4bee208869ec4aea2dc8ebdc38c5 Mon Sep 17 00:00:00 2001 From: Justin Hammond Date: Tue, 6 Aug 2013 13:52:48 -0500 Subject: [PATCH 1/2] Added utc option --- ttyclock.c | 12 +++++++++++- ttyclock.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ttyclock.c b/ttyclock.c index 743e269..5e3fb3a 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -78,6 +78,9 @@ init(void) ttyclock->geo.w = (ttyclock->option.second) ? SECFRAMEW : NORMFRAMEW; ttyclock->geo.h = 7; ttyclock->tm = localtime(&(ttyclock->lt)); + if(ttyclock->option.utc) { + ttyclock->tm = gmtime(&(ttyclock->lt)); + } ttyclock->lt = time(NULL); update_hour(); @@ -145,6 +148,9 @@ update_hour(void) char tmpstr[128]; ttyclock->tm = localtime(&(ttyclock->lt)); + if(ttyclock->option.utc) { + ttyclock->tm = gmtime(&(ttyclock->lt)); + } ttyclock->lt = time(NULL); ihour = ttyclock->tm->tm_hour; @@ -459,7 +465,7 @@ main(int argc, char **argv) /* Default blink */ ttyclock->option.blink = False; - while ((c = getopt(argc, argv, "tvsrcihfDBd:C:")) != -1) + while ((c = getopt(argc, argv, "utvsrcihfDBd:C:")) != -1) { switch(c) { @@ -470,6 +476,7 @@ main(int argc, char **argv) " -c Set the clock at the center of the terminal \n" " -C [0-7] Set the clock color \n" " -t Set the hour in 12h format \n" + " -u Use UTC time \n" " -r Do rebound the clock \n" " -f format Set the date format \n" " -v Show tty-clock version \n" @@ -487,6 +494,9 @@ main(int argc, char **argv) free(ttyclock->option.format); exit(EXIT_SUCCESS); break; + case 'u': + ttyclock->option.utc = True; + break; case 'v': puts("TTY-Clock 2 © devel version"); free(ttyclock); diff --git a/ttyclock.h b/ttyclock.h index 469e8f7..d8b63b9 100644 --- a/ttyclock.h +++ b/ttyclock.h @@ -65,6 +65,7 @@ typedef struct Bool center; Bool rebound; Bool date; + Bool utc; char *format; int color; long delay; From e98c3805f5066afb58d83c567306dc5a9a48970f Mon Sep 17 00:00:00 2001 From: Justin Hammond Date: Tue, 6 Aug 2013 13:53:55 -0500 Subject: [PATCH 2/2] Updated README to add -u --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index ab94f93..1cff61f 100755 --- a/README +++ b/README @@ -3,6 +3,7 @@ usage : tty-clock [-sctrvihDB] [-C [0-7]] [-f format] -c Set the clock at the center of the terminal -C [0-7] Set the clock color -t Set the hour in 12h format + -u Use UTC time -r Do rebound the clock -f format Set the date format -v Show tty-clock version