Difference between revisions of "AMOS:Time and Date"
Spellcoder (talk | contribs) (email from the AMOS-list (1993) about getting the time and date) |
(No difference)
|
Latest revision as of 22:10, 27 September 2007
Date: Sun, 30 May 1993 15:06:58 +0000
Content-Identifier: RE: Date (038) Ti...
From: Jean-Francois Dreyfuss <dreyfusj@issy.cnet.fr>
To: amos-list@access.digex.net
Subject: RE: Date & Time proc.
This should answer your question Mike!
'----------------------------------
' How to get TIME and DATE in AMOS
'----------------------------------
'
_DATE$ : Print Param$
_TIME$ : Print Param$
'
Procedure _DATE$
'
' Call DOS DateStamp function
T$=Space$(12)
Dreg(1)=Varptr(T$)
RIEN=Doscall(-192)
NJ=Leek(Varptr(T$))
'
' Find this year's first day
A=1978 : JOUR=7
Do
BIS=0 : If(A and 3)=0 : BIS=1 : End If
Exit If NJ-365-BIS<0
Add JOUR,1+BIS : If JOUR>7 : Add JOUR,-7 : End If
Add NJ,-365-BIS
Inc A
Loop
'
' Find month
M=1
Do
Read N
Exit If NJ-N<0
Add NJ,-N : Inc M
Loop
Inc NJ
'
' Create the string
J$=Mid$(Str$(NJ),2) : If Len(J$)<2 : J$="0"+J$ : End If
M$=Mid$(Str$(M),2) : If Len(M$)<2 : M$="0"+M$ : End If
A$=Mid$(Str$(A),2)
DATE$=J$+"-"+M$+"-"+A$
'
' Length of each month
Data 31,28+BIS,31,30,31,30,31,31,30,31,30,31
'
End Proc[DATE$]
Procedure _TIME$
'
' Call DOS function
T$=Space$(12)
Dreg(1)=Varptr(T$)
RIEN=Doscall(-192)
MN=Leek(Varptr(T$)+4)
SEC=Leek(Varptr(T$)+8)
'
' Minutes calculation
H=MN/60 : H$=Mid$(Str$(H),2) : If Len(H$)<2 : H$="0"+H$ : End If
M=MN mod 60 : M$=Mid$(Str$(M),2) : If Len(M$)<2 : M$="0"+M$ : End If
'
' Seconds calculation
S=SEC/50 : S$=Mid$(Str$(S),2) : If Len(S$)<2 : S$="0"+S$ : End If
'
' Final string
TIME$=H$+":"+M$+":"+S$
'
End Proc[TIME$]