home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / setdate.c < prev    next >
C/C++ Source or Header  |  1993-10-14  |  2KB  |  90 lines

  1. /*
  2.  * File......: SETDATE.C
  3.  * Author....: Dave Pearson
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Dave Pearson
  7.  * Date......: $Date$
  8.  * Revision..: $Revision$
  9.  * Log file..: $Logfile$
  10.  *
  11.  * This is an original work by Dave Pearson and is placed in the public
  12.  * domain.
  13.  *
  14.  * Modification history:
  15.  * ---------------------
  16.  *
  17.  * $Log$
  18.  *
  19.  */
  20.  
  21. // NOTE: This code has been written for and compiled with Borland C++
  22. //       Version 3.1
  23. //
  24.  
  25. #include <extend.h>
  26. #include "internal.h"
  27.  
  28. Boolean SetDosDate(char, char, int);
  29.  
  30. /*  $DOC$
  31.  *  $FUNCNAME$
  32.  *      GT_SETDATE()
  33.  *  $CATEGORY$
  34.  *      Date
  35.  *  $ONELINER$
  36.  *      Set the DOS system date.
  37.  *  $SYNTAX$
  38.  *      GT_SetDate(<dDate>) --> lSetOk
  39.  *  $ARGUMENTS$
  40.  *      <dDate> is a date parameter.
  41.  *  $RETURNS$
  42.  *      If the date was set ok, GT_SetDate() returns true (.T.), if not
  43.  *      it returns false (.F.).
  44.  *  $DESCRIPTION$
  45.  *      GT_SetDate() can be used to set the DOS system date to a new
  46.  *      value.
  47.  *  $EXAMPLES$
  48.  *      // Set the DOS system date forward one week.
  49.  *
  50.  *      ? GT_SetDate(date()+7)
  51.  *  $SEEALSO$
  52.  *      GT_SETTIME()
  53.  *  $END$
  54.  */
  55.  
  56. CLIPPER GT_SetDate()
  57. {
  58.         char    *Date;
  59.         Boolean Result = FALSE;
  60.  
  61.         if (PCOUNT == 1 && ISDATE(1))
  62.         {
  63.                 Date = _pards(1);
  64.                 if (Date[0] != ' ')
  65.                 {
  66.                         Result = SetDosDate((char) _GT_Internal_StringAsInt(Date,6,7),
  67.                                             (char) _GT_Internal_StringAsInt(Date,4,5),
  68.                                             _GT_Internal_StringAsInt(Date,0,3));
  69.                 }
  70.         }
  71.         _retl(Result);
  72. }
  73.  
  74. /*****************************************************************************
  75. * Function: SetDosDate()                                                     *
  76. * Syntax..: Boolean SetDosDate(char Day, char Month, int Year)               *
  77. * Usage...: Internal function to call the DOS set date function.             *
  78. * By......: David A Pearson                                                  *
  79. *****************************************************************************/
  80.  
  81. static Boolean SetDosDate(char Day, char Month, int Year)
  82. {
  83.         asm     Mov     AH,0x2B
  84.         asm     Mov     DH,Month
  85.         asm     Mov     DL,Day
  86.         asm     Mov     CX,Year
  87.         asm     Int     0x21
  88.         return(_AL != 0xFF);
  89. }
  90.