home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / TODAY.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  693b  |  39 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  TODAY.C - Return today's date in a scalar date format.
  5. **
  6. **  public domain by Bob Stout - uses Ray Gardner's SCALDATE.C
  7. */
  8.  
  9. #include <time.h>
  10. #include "scaldate.h"
  11.  
  12.  
  13. long today(void)
  14. {
  15.       time_t tnow;
  16.       struct tm *tmnow;
  17.  
  18.       time(&tnow);
  19.       tmnow = localtime(&tnow);
  20.       return ymd_to_scalar(tmnow->tm_year + 1900, tmnow->tm_mon + 1,
  21.             tmnow->tm_mday);
  22. }
  23.  
  24. #ifdef TEST
  25.  
  26. #include <stdio.h>
  27.  
  28. main()
  29. {
  30.       unsigned yr, mo, dy;
  31.       long dnow = today();
  32.  
  33.       scalar_to_ymd(dnow, &yr, &mo, &dy);
  34.       printf("Today is %d/%d/%d\n", mo, dy, yr);
  35.       return 0;
  36. }
  37.  
  38. #endif /*TEST */
  39.