|
Lines 400-407
Link Here
|
| 400 |
struct tm *lt; |
400 |
struct tm *lt; |
| 401 |
char *p; |
401 |
char *p; |
| 402 |
time_t now; |
402 |
time_t now; |
| 403 |
int this_year; |
403 |
int this_year, maybe_today; |
| 404 |
|
404 |
|
|
|
405 |
maybe_today = 1; |
| 405 |
(void)time(&now); |
406 |
(void)time(&now); |
| 406 |
|
407 |
|
| 407 |
if (!strcasecmp(timearg, "now")) { /* now */ |
408 |
if (!strcasecmp(timearg, "now")) { /* now */ |
|
Lines 454-459
Link Here
|
| 454 |
badtime(); |
455 |
badtime(); |
| 455 |
/* FALLTHROUGH */ |
456 |
/* FALLTHROUGH */ |
| 456 |
case 6: |
457 |
case 6: |
|
|
458 |
maybe_today = 0; |
| 457 |
lt->tm_mday = ATOI2(timearg); |
459 |
lt->tm_mday = ATOI2(timearg); |
| 458 |
if (lt->tm_mday < 1 || lt->tm_mday > 31) |
460 |
if (lt->tm_mday < 1 || lt->tm_mday > 31) |
| 459 |
badtime(); |
461 |
badtime(); |
|
Lines 468-475
Link Here
|
| 468 |
lt->tm_sec = 0; |
470 |
lt->tm_sec = 0; |
| 469 |
if ((shuttime = mktime(lt)) == -1) |
471 |
if ((shuttime = mktime(lt)) == -1) |
| 470 |
badtime(); |
472 |
badtime(); |
| 471 |
if ((offset = shuttime - now) < 0) |
473 |
|
| 472 |
errx(1, "that time is already past."); |
474 |
if ((offset = shuttime - now) < 0) { |
|
|
475 |
if (!maybe_today) |
| 476 |
errx(1, "that time is already past."); |
| 477 |
|
| 478 |
/* |
| 479 |
* If the user only gave a time, assume that |
| 480 |
* any time earlier than the current time |
| 481 |
* was intended to be that time tomorrow. |
| 482 |
*/ |
| 483 |
lt->tm_mday++; |
| 484 |
if ((shuttime = mktime(lt)) == -1) |
| 485 |
badtime(); |
| 486 |
if ((offset = shuttime - now) < 0) { |
| 487 |
warnx("tomorrow is before today?"); |
| 488 |
abort(); |
| 489 |
} |
| 490 |
} |
| 473 |
break; |
491 |
break; |
| 474 |
default: |
492 |
default: |
| 475 |
badtime(); |
493 |
badtime(); |