home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 463.lha / Date_routines / natldate.c < prev    next >
C/C++ Source or Header  |  1991-01-04  |  1KB  |  46 lines

  1. /*****
  2.                               natldate()
  3.  
  4.       This function returns the date in different formats.
  5.  
  6.    Argument list:    char *buff     to hold the resulting date string
  7.                      int month      the month
  8.                      int day        the day
  9.                      int year       the year
  10.                      int sep        the character used to separate dates
  11.                      int where      which format to use:
  12.                                        0 = US       mm/dd/yy
  13.                                        1 = Europe   dd/mm/yy
  14.                                        2 = Japan    yy/mm/dd
  15.  
  16.    Return value:     void
  17.  
  18. *****/
  19.  
  20. #include <stdio.h>
  21. #include <string.h>
  22.  
  23. void natldate(char *buff, int day, int month, int year, int sep, int where)
  24. {
  25.    char form[20];
  26.  
  27.    while (year > 100)
  28.       year -= 100;
  29.    strcpy(form, "%02d%c%02d%c%02d");   /* Zero padding   */
  30.  
  31.    switch (where) {
  32.       case 0:                 /* US       */
  33.          sprintf(buff, form, month, sep, day, sep, year);
  34.          break;
  35.       case 1:                 /* Europe   */
  36.          sprintf(buff, form, day, sep, month, sep, year);
  37.          break;
  38.       case 2:                 /* Japan    */
  39.          sprintf(buff, form, year, sep, month, sep, day);
  40.          break;
  41.      default:                 /* Default is US */
  42.          sprintf(buff, form, month, sep, day, sep, year);
  43.          break;
  44.    }
  45. }
  46.