"yesterdate" function?
Arnold D. Robbins {EUCC}
arnold at emory.uucp
Thu Jan 5 03:40:13 AEST 1989
In article <19100001 at hpficad.HP.COM> mcr at hpficad.HP.COM (Matt Reprogle) writes:
>I need a way to get yesterday's date in YYMMDD format in a Unix script and put
>it in a file. I don't want to write a C program implementing an entire
>calendar to do it.
>
>Can anyone help?
This is too hard to pass up.
#include <time.h>
#define ONEDAY (24 * 60 * 60) /* seconds in a day */
main ()
{
long yesterday;
struct tm* then;
(void) time (& yesterday);
yesterday -= ONEDAY;
then = localtime (& yesterday);
(void) printf ("%d%02d%02d\n", then->tm_year,
then->tm_mon, then->tm_mday);
return 0;
}
--
"Unix is a Registered | Arnold Robbins -- Emory University Computing Center
Bell of AT&T Trademark | DOMAIN: arnold at unix.cc.emory.edu
Laboratories." | UUCP: gatech!emory!arnold PHONE: +1 404 727-7636
-- Donn Seeley | BITNET: arnold at emoryu1 FAX: +1 404 727-2599
More information about the Comp.unix.questions
mailing list