Re: DOS Date and Time sta

Area:    Quik_Bas
  Msg:    #242
 Date:    03-18-93 14:31 (Public) 
 From:    Dick Dennison            
 To:      Robert Church            
 Subject: Re: DOS Date and Time sta
RC> How do you convert the bit-mapped DOS date and time stamps in the DTA 
RC> QB useable variables?  I'd like to convert them to INTEGERs for:
  
FUNCTION fixdate$ (parm%)
'Date and time are in packed format - these are the breakouts
'bits 00h-04h = day (1-31)
'bits 05h-08h = month (1-12)
'bits 09h-0Fh = year (relative to 1980)
 
day% = parm% AND 31        'get bits 0-4
dayz$ = LTRIM$(STR$(day%))
IF LEN(dayz$) = 1 THEN dayz$ = "0" + (dayz$)  'Parse and add leading 0 if 
needed
parm% = parm% \ 32         'shift left 5
month% = parm% AND 15      'get bits 5-8
parm% = parm% \ 16         'shift left 4
year% = (parm% AND 255) + 80    'get bits 9-15 and add to 1980
moddate$ = dayz$ + mon$(month%) + LTRIM$(STR$(year%))  'Format is 20-Oct-9
0
 
fixdate$ = moddate$
 
END FUNCTION
 
FUNCTION fixtime$ (parm%)
'Date and time are in packed format - these are the breakouts
'bits 00h-04h = 2 second incs (0-29)
'bits 05h-0Ah = minutes (0-59)
'bits 0Bh-0Fh = hours (0-23)
 
temp& = parm%
IF parm% < 0 THEN temp& = temp& + 65536  'Check for sign (+ -)
secs% = (temp& AND 31) * 2  'get bits 0-4 and multiply by 2
temp& = temp& \ 32          'shift right 5
mins% = temp& AND 63        'get bits 5-10
temp& = temp& \ 64          'shift right 6
hours% = temp& AND 31       'get bits 11-15
sec$ = LTRIM$(STR$(secs%))
IF LEN(sec$) = 1 THEN sec$ = "0" + sec$    'Parse and add leading 0's
min$ = LTRIM$(STR$(mins%))
IF LEN(min$) = 1 THEN min$ = "0" + min$    'if needed
hour$ = LTRIM$(STR$(hours%))
IF LEN(hour$) = 1 THEN hour$ = "0" + hour$
 
modtime$ = hour$ + ":" + min$ + ":" + sec$  'Format is 01:30:46
fixtime$ = modtime$
 
END FUNCTION 
 
'Does that help - It's not an integer, but a string.
 

--- VP [DOS] V4.09e
 * Origin: The MailMan  (914)374-3903 NY Quick Share Pt #7 *HST (1:272/34)


Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET