comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » A little handy date function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
A little handy date function [message #29885] Mon, 25 March 2002 08:37
G Karas is currently offline  G Karas
Messages: 12
Registered: March 2002
Junior Member
I was trying to make some unique filenames...

first I tried the randomn() function, but it always gave
back the same number for the same seed...

and the bin_date(systime()) combination, did not quite make it ;
it missed leading zeroes..

so i thought, why not posting my little routine:


--- cut here ------------cut here -------------

FUNCTION UNIQUE_DATE

; little function to create *correct* timestamps
; the existing bin_date function, does not add
; zeroes... so we never know where what is...
; works for 24 hours clock..
; not fixed for am-pm clocks...


aq = bin_date(systime()) ; get the systime and put it in an array

uq = string(aq)

if aq[1] LT 10 then uq[1] = '0' + deblank(uq[1]) ; month
if aq[2] LT 10 then uq[2] = '0' + deblank(uq[2]) ; day
if aq[3] LT 10 then uq[3] = '0' + deblank(uq[3]) ; hour
if aq[4] LT 10 then uq[4] = '0' + deblank(uq[4]) ; min
if aq[5] LT 10 then uq[5] = '0' + deblank(uq[5]) ; sec


datearr = uq[0] + uq[1] + uq[2] + '_' + $
uq[3] + uq[4] + uq[5]

date_string = deblank(datearr)

return, date_string

END

FUNCTION DEBLANK, myTEXT

deresult = strcompress(string(myTEXT), /REMOVE_ALL)
return, deresult

END

--- cut here ------------cut here -------------
[Message index]
 
Read Message
Previous Topic: _STRICT_EXTRA keyword
Next Topic: Re: days of the week

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:03:20 PDT 2025

Total time taken to generate the page: 0.00460 seconds