home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume8 / phoon / parsetime.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-02-26  |  1.7 KB  |  63 lines

  1. /* parsetime.c - parse a date/time and display the results
  2.  
  3. ver  date   who remarks
  4. --- ------- --- -------------------------------------------------------------
  5. 01A 15nov86 JP  Written.
  6.  
  7. Copyright (C) 1986 by Jef Poskanzer.  Permission to use, copy,
  8. modify, and distribute this software and its documentation for any
  9. purpose and without fee is hereby granted, provided that this copyright
  10. notice appear in all copies and in all supporting documentation.  No
  11. representation is made about the suitability of this software for any
  12. purpose.  It is provided "as is" without express or implied warranty.
  13.  
  14. */
  15.  
  16. static char copyright[] = "\nCopyright (C) 1986 by Jef Poskanzer.\n";
  17.  
  18.  
  19. #include "tws.h"
  20. #include <stdio.h>
  21.  
  22.  
  23. main( argc, argv )
  24. int argc;
  25. char *argv[];
  26.     {
  27.     char buf[200];
  28.     int i;
  29.     struct tws *twp;
  30.  
  31.     strcpy( buf, "" );
  32.     for ( i = 1; i < argc; i++ )
  33.     {
  34.     if ( i > 1 )
  35.         strcat( buf, " " );
  36.     strcat( buf, argv[i] );
  37.     }
  38.  
  39.     twp = dparsetime( buf );
  40.     if ( twp == NULL )
  41.     {
  42.     fprintf( stderr, "illegal date/time: %s\n", buf );
  43.     exit( 1 );
  44.     }
  45.  
  46.     printf( "dparsetime( \"%s\" ):\n", buf );
  47.     printf( "  tw_sec = %d\n", twp->tw_sec );
  48.     printf( "  tw_min = %d\n", twp->tw_min );
  49.     printf( "  tw_hour = %d\n", twp->tw_hour );
  50.     printf( "  tw_mday = %d\n", twp->tw_mday );
  51.     printf( "  tw_mon = %d\n", twp->tw_mon );
  52.     printf( "  tw_year = %d\n", twp->tw_year );
  53.     printf( "  tw_wday = %d\n", twp->tw_wday );
  54.     printf( "  tw_yday = %d\n", twp->tw_yday );
  55.     printf( "  tw_zone = %d\n", twp->tw_zone );
  56.     printf( "  tw_clock = %ld\n", twp->tw_clock );
  57.     printf( "  tw_flags = %d (0x%04x)\n", twp->tw_flags, twp->tw_flags );
  58.     printf( "\n" );
  59.     printf( "dasctime: %s\n", dasctime( twp, 0 ) );
  60.  
  61.     exit( 0 );
  62.     }
  63.