/* YYYYMMDD.exe Displays date in form YYYY-MM-DD without a CrLf see yyyyymmdd.use YYMMDD 1.6 Copyright: (c) 2001-2017 Roedy Green, Canadian Mind Products #101 - 2536 Wark Street Victoria, BC Canada V8T 4G8 tel:(250) 361-9093 mailto:roedyg@mindprod.com http://mindprod.com Compiled as a Windows console App, without precompiled headers. For Visual C++ Express options see http://mindprod.com/jgloss/cpp.html#COMPILING Version History: 1.6 2011-09-23 port the DOS assembler version */ /* ==================================== */ #include /* exit, putenv, _splitpath */ #include /* fclose, fgetc, printf, remove, rename, setvbuf */ #include /* SYSTEMTIME */ /* ==================================== */ /* P R O T O T Y P E S */ void banner(void); int main (int argc, char *argv[]); /* ==================================== */ int main(int argc, char *argv[]) { char* separator = (argc == 2)? argv[1] : "-"; /* build local System time control block */ SYSTEMTIME tcb; /* get system date/time: year=yyyy, month=1..12, day=1..31, hour=0..23, minute=0..59, second=0..59, millis=0..999 system time fields are all 16 bit unsigned. */ // GetSystemTime( &tcb ); // gets UTC GetLocalTime( &tcb ); // local TZ // display YYYY-MM-DD printf( "%04d%s%02d%s%02d", tcb.wYear, separator, tcb.wMonth, separator, tcb.wDay ); return( 0 ); } /* embedded display copyright banner, with shaded splashes. There is no possible syntax error to trigger it. */ void banner(void) { printf("\n" "\xb0\xb1\xb2\xdb" " YYMMDD 1.6 " "\xdb\xb2\xb1\xb0" "\nDisplays date in form YYYY-MM-DD without a CrLf" "\nCopyright: (c) 2001-2017 Roedy Green, Canadian Mind Products" "\n" "#101 - 2536 Wark Street, Victoria, BC Canada V8T 4G8" "\n" "tel:(250) 361-9093 mailto:roedyg@mindprod.com http://mindprod.com" "\n" "May be used freely for non-military use only" "\n\n"); } /* -30- */