KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q27931: Sample Program That Makes OS/2 Call DosGetDateTime

Article: Q27931
Product(s): See article
Version(s): 6.00 6.00b 7.00
Operating System(s): OS/2
Keyword(s): ENDUSER | | mspl13_basic
Last Modified: 31-JAN-1990

Below is a sample program that CALLs the OS/2 routine DosGetDateTime.

This information applies to Microsoft BASIC Compiler Versions 6.00 and
6.00b for MS OS/2 and to Microsoft BASIC Professional Development
System (PDS) Version 7.00.

' The user-defined TYPE and function DECLARE are found in
' BSEDOSPE.BI

TYPE DateTime
     Hour        AS STRING*1
     Minutes     AS STRING*1
     Seconds     AS STRING*1
     Hundredths  AS STRING*1
     Day         AS STRING*1
     Month       AS STRING*1
     Year        AS INTEGER
     Timezone    AS INTEGER
     DayOfWeek   AS STRING*1
END TYPE

DECLARE FUNCTION DosGetDateTime%(SEG P1 AS DateTime)
DECLARE FUNCTION FDAY$ (x%)

DIM dayt AS DateTime
CLS
x=DosGetDateTime%(dayt)

IF (x) THEN
  Print "An error occurred.  The error number is : ";x
ELSE
  t$=str$(asc(dayt.hour))+":"+str$(asc(dayt.minutes))+":"_
     +str$(asc(dayt.seconds))  +":"+str$(asc(dayt.hundredths))

  d$=str$(asc(dayt.month))+"/"+right$(str$(asc(dayt.day)),2)_
      +"/"+right$(str$(dayt.year),4)

  Print "TIME : ";t$
  Print "DATE : ";d$
  print "Number of hours from Greenwich Mean Time : ";(dayt.timezone)/60%
  print "The day of the week : "; fday$(asc(dayt.dayofweek))
END IF
end

FUNCTION FDAY$(x%) STATIC

SELECT CASE x%
   case 0
       fday$="Sunday"
   case 1
       fday$="Monday"
   case 2
       fday$="Tuesday"
   case 3
       fday$="Wednesday"
   case 4
       fday$="Thursday"
   case 5
       fday$="Friday"
   case 6
       fday$="Saturday"
   case else
       fday$="XXXXXXXXX"
  END SELECT
END FUNCTION

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.