;Demonstrates an easy date conversion scheme v1.00 

;*************************************************************************
;* Written by:  Symantec ASPECT Assist                                       *
;*                                                                           *                                                                             
;* This script file will give the user the option of either capturing data   *
;* in half hour increments, or in 24 hour increments. The Capture file will  *
;* close after a predefined period of inactivity on the port.                *
;*                                                                           *
;* This ASPECT script is intended only as a sample of ASPECT programming.    *
;* Symantec makes no warranty of any kind, express or implied, including     *
;* without limitation, any warranties of merchantability and/or fitness      *
;* for a particular purpose.  Use of this program is at your own risk.       *
;*                                                                           *
;* Technical Support is not provided on this script.                         *                                                                          *
;*****************************************************************************




;*************************************************************************
;* Global Variables                                                      *
;*************************************************************************
string  szTimeString, szThisDate, szThatDate, szNDay, szTimeAdd, szDayString
integer iDay, iDayYear, iLeapYear, iTimeAdd, iNDay, iNDayYear, iNLeapYear
long    lTodaysDate, lEndDate



;*************************************************************************
;* Main Procedure ()                                                     *                    
;* This procedure kicks off the whole procedure.                         *
;*                                                                       *
;* GLOBALS: NONE                                                         *
;* CALLS: NONE                                                           *
;* CALLED BY: NONE                                                       *
;*************************************************************************
proc main
   CalculateDate ()
endproc



;*************************************************************************
;* CalculateDate ()                                                      *
;* This procedure asks the user for a number of days so that it can      *
;* calculate from Today's date until that time. Then it multiplies this  *
;* number by 86400 which is the number of seconds in 24 hours. Then it   *
;* figures out what day of the week that will be, and shows how many days*
;* it will be until the weekend.                                         *
;*                                                                       *
;* GLOBALS: szTimeString, szThisDate, szThatDate, szNDay, szTimeAdd,     *
;*          szDayString, lTodaysDate, lEndDate, iDay, iDayYear, iLeapYear*
;*          iTimeAdd, iNDay, iNDayYear, iNLeapYear                       *
;* CALLS: None                                                           *
;* CALLED BY: MAIN                                                       *
;*************************************************************************
proc CalculateDate
string szUserMSG, szTAString                     ;Local Variables.
integer iLessTime

   sdlginput "Information" "Enter a number of days for us to add to today's date:" szTimeAdd
   atoi szTimeAdd iTimeAdd                       ;Convert string to integer.

   if iTimeAdd < 0                               ;Determine how many days it
      iLessTime = (iTimeAdd*-1)                  ;was or will be.
      strfmt szTAString "%i days ago it was" iLessTime
   elseif iTimeAdd == 0
      szTAString = "Today it is"
   elseif iTimeAdd == 1
      szTAString = "In 1 day it will be"
   else
      strfmt szTAString "In %i days it will be" iTimeAdd
   endif

   ltimemisc $LTIME iDay iDayYear iLeapYear      ;Get current day from system.
   lTodaysDate = $LTIME                              ;Determine today's date.
   lEndDate    = lTodaysDate + (iTimeAdd*86400)  ;Multiply days by seconds.
   ltimemisc lEndDate iNDay, iNDayYear, iNLeapYear ;extract the date.

   ltimestrs lTodaysDate szThisDate szTimeString ;Convert date to xx/xx/xx
   ltimestrs lEndDate    szThatDate szTimeString ;Convert date to xx/xx/xx

   switch iNDay                                  ;Determine the day of the week,
      case 1                                     ;and add some information.
         szNDay = "Sunday"
         szDayString = "the Weekend!"
      endcase
      case 2
         szNDay = "Monday"
         szDayString = "5 days till the Weekend!"
      endcase
      case 3
         szNDay = "Tuesday"
         szDayString = "4 days till the Weekend!"         
      endcase
      case 4
         szNDay = "Wednesday"
         szDayString = "3 days till the Weekend!"         
      endcase
      case 5
         szNDay = "Thursday"
         szDayString = "2 days till the Weekend!"         
      endcase
      case 6
         szNDay = "Friday"
         szDayString = "Only 1 more day till the Weekend!"         
      endcase
      case 7
         szNDay = "Saturday"
         szDayString = "The Weekend!"         
      endcase
   endswitch
                                               ;Format gathered information
                                               ;into a string that will be
                                               ;reported in a user message.
   strfmt szUserMSG "Today's date is %s. %s %s. A %s, and %s" szThisDate szTAString szThatDate szNDay szDayString

   usermsg szUserMSG                           ;Display information gathered.
endproc
