Added utc option

reverse-branch
Justin Hammond 13 years ago
parent 7a789dc0f8
commit 6ff646f569
  1. 12
      ttyclock.c
  2. 1
      ttyclock.h

@ -78,6 +78,9 @@ init(void)
ttyclock->geo.w = (ttyclock->option.second) ? SECFRAMEW : NORMFRAMEW; ttyclock->geo.w = (ttyclock->option.second) ? SECFRAMEW : NORMFRAMEW;
ttyclock->geo.h = 7; ttyclock->geo.h = 7;
ttyclock->tm = localtime(&(ttyclock->lt)); ttyclock->tm = localtime(&(ttyclock->lt));
if(ttyclock->option.utc) {
ttyclock->tm = gmtime(&(ttyclock->lt));
}
ttyclock->lt = time(NULL); ttyclock->lt = time(NULL);
update_hour(); update_hour();
@ -145,6 +148,9 @@ update_hour(void)
char tmpstr[128]; char tmpstr[128];
ttyclock->tm = localtime(&(ttyclock->lt)); ttyclock->tm = localtime(&(ttyclock->lt));
if(ttyclock->option.utc) {
ttyclock->tm = gmtime(&(ttyclock->lt));
}
ttyclock->lt = time(NULL); ttyclock->lt = time(NULL);
ihour = ttyclock->tm->tm_hour; ihour = ttyclock->tm->tm_hour;
@ -459,7 +465,7 @@ main(int argc, char **argv)
/* Default blink */ /* Default blink */
ttyclock->option.blink = False; ttyclock->option.blink = False;
while ((c = getopt(argc, argv, "tvsrcihfDBd:C:")) != -1) while ((c = getopt(argc, argv, "utvsrcihfDBd:C:")) != -1)
{ {
switch(c) switch(c)
{ {
@ -470,6 +476,7 @@ main(int argc, char **argv)
" -c Set the clock at the center of the terminal \n" " -c Set the clock at the center of the terminal \n"
" -C [0-7] Set the clock color \n" " -C [0-7] Set the clock color \n"
" -t Set the hour in 12h format \n" " -t Set the hour in 12h format \n"
" -u Use UTC time \n"
" -r Do rebound the clock \n" " -r Do rebound the clock \n"
" -f format Set the date format \n" " -f format Set the date format \n"
" -v Show tty-clock version \n" " -v Show tty-clock version \n"
@ -487,6 +494,9 @@ main(int argc, char **argv)
free(ttyclock->option.format); free(ttyclock->option.format);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
case 'u':
ttyclock->option.utc = True;
break;
case 'v': case 'v':
puts("TTY-Clock 2 © devel version"); puts("TTY-Clock 2 © devel version");
free(ttyclock); free(ttyclock);

@ -65,6 +65,7 @@ typedef struct
Bool center; Bool center;
Bool rebound; Bool rebound;
Bool date; Bool date;
Bool utc;
char *format; char *format;
int color; int color;
long delay; long delay;

Loading…
Cancel
Save