Added option to change date format.

reverse-branch
Tom Adams 17 years ago
parent d2459f135a
commit f119cd20b0
  1. 12
      ttyclock.c
  2. 2
      ttyclock.h

@ -158,7 +158,7 @@ update_hour(void)
/* Set date string */
strftime(ttyclock->date.datestr,
sizeof(ttyclock->date.datestr),
"%d/%m/%Y",
ttyclock->option.format,
ttyclock->tm);
/* Set seconds */
@ -403,13 +403,18 @@ main(int argc, char **argv)
{"twelve", 0, NULL, 't'},
{"rebound", 0, NULL, 'r'},
{"center", 0, NULL, 'c'},
{"format", 1, NULL, 'f'},
{NULL, 0, NULL, 0}
};
/* Alloc ttyclock */
ttyclock = malloc(sizeof(ttyclock_t));
while ((c = getopt_long(argc,argv,"tvsrcih",
/* Date format */
ttyclock->option.format = malloc(sizeof(char)*100);
strncpy(ttyclock->option.format, "%d/%m/%Y", 100);
while ((c = getopt_long(argc,argv,"tvsrcihf:",
long_options, NULL)) != -1)
{
switch(c)
@ -442,6 +447,9 @@ main(int argc, char **argv)
case 'r':
ttyclock->option.rebound = True;
break;
case 'f':
strncpy(ttyclock->option.format, optarg, 100);
break;
}
}

@ -55,6 +55,7 @@
-c, --center Set the clock at the center of the terminal \n\
-t, --twelve Set the hour in 12h format \n\
-r, --rebound Do rebound the clock \n\
-f, --format Set the date format \n\
-v, --version Show tty-clock version \n\
-i, --info Show some info about tty-clock \n\
-h, --help Show this page "
@ -74,6 +75,7 @@ typedef struct
Bool twelve;
Bool center;
Bool rebound;
char *format;
} option;
/* Clock geometry */

Loading…
Cancel
Save