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

Home » Public Forums » archive » Re: A little handy date function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: A little handy date function [message #29879] Mon, 25 March 2002 10:52
G Karas is currently offline  G Karas
Messages: 12
Registered: March 2002
Junior Member
yes indeed! that is a lot more elegant!
thanks a lot mate :)
Re: A little handy date function [message #29881 is a reply to message #29879] Mon, 25 March 2002 10:19 Go to previous message
Andrew Loughe is currently offline  Andrew Loughe
Messages: 9
Registered: October 1998
Junior Member
G Karas wrote:
>
> 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


How about this attempt at a simpler solution...

aq = BIN_DATE( SYSTIME() )

uq = STRING( aq[0], aq[1], aq[2], '_', aq[3], aq[4], aq[5], $
format='(i4.4, i2.2, i2.2, a, i2.2, i2.2, i2.2)' )

return, uq

--
Andrew Loughe =====================================================
NOAA/OAR/FSL/AD R/FS5 | email: Andrew.Loughe@noaa.gov
325 Broadway | wwweb: www-ad.fsl.noaa.gov/users/loughe
Boulder, CO 80305-3328 | phone: 303-497-6211 fax: 303-497-6301
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Now... (Random Numbers)
Next Topic: REBIN Question

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

Current Time: Wed Oct 08 13:39:22 PDT 2025

Total time taken to generate the page: 0.00472 seconds