version 1.22, 2003/04/06 18:40:14 |
version 1.23, 2003/04/14 02:04:58 |
|
|
/* |
/* |
* dateconv -- |
* dateconv -- |
* Convert the snapshot time in command line given in the format |
* Convert the snapshot time in command line given in the format |
* [[CC]YY][MMDD]hhmm[.SS]] to a time_t. |
* [[[CC]YY]MMDD]hhmm[.SS]] to a time_t. |
* Derived from atime_arg1() in usr.bin/touch/touch.c |
* Derived from atime_arg1() in usr.bin/touch/touch.c |
*/ |
*/ |
time_t |
time_t |
|
|
if ((t = localtime(&timet)) == NULL) |
if ((t = localtime(&timet)) == NULL) |
err(1, "localtime"); |
err(1, "localtime"); |
|
|
/* [[CC]YY][MMDD]hhmm[.SS] */ |
/* [[[CC]YY]MMDD]hhmm[.SS] */ |
if ((p = strchr(arg, '.')) == NULL) |
if ((p = strchr(arg, '.')) == NULL) |
t->tm_sec = 0; /* Seconds defaults to 0. */ |
t->tm_sec = 0; /* Seconds defaults to 0. */ |
else { |
else { |
|
|
timet = mktime(t); |
timet = mktime(t); |
if (timet == -1) |
if (timet == -1) |
terr: errx(1, |
terr: errx(1, |
"out of range or illegal time specification: [[CC]YY][MMDD]hhmm[.SS]"); |
"out of range or illegal time specification: [[[CC]YY[MMDD]hhmm[.SS]"); |
return (timet); |
return (timet); |
} |
} |
|
|
|
|
|
|
fprintf(stderr, |
fprintf(stderr, |
"usage: %s [-#] [-csT] [-f file] [-t tty] [-h host]" |
"usage: %s [-#] [-csT] [-f file] [-t tty] [-h host]" |
" [-d [[CC]YY][MMDD]hhmm[.SS]] [user ...]\n", __progname); |
" [-d [[[CC]YY]MMDD]hhmm[.SS]] [user ...]\n", __progname); |
exit(1); |
exit(1); |
} |
} |