>?log10($922337203685477)
>
>************************************************** *-- Class: app (m:\rad\vfprc\app.vcx) *-- ParentClass: custom *-- BaseClass: custom *-- Time Stamp: 07/08/06 11:52:02 AM * test code: o=createobject("t2s") lcD=o.t2s(datetime()) ?lcD, o.s2t(lcd) Define Class t2s As Custom Name = "app" starttime = { :} *-- need this for t2s and others. trnN2S="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ()+-/#$%!" Procedure Init This.starttime=Datetime() *--------------------------------------------------- Procedure t2s(tt) Local nDaynr, nSecs *-- dn 15/06/06 nDaynr=Ttod(tt)-{^1980-01-01} nSecs=Int(tt-Dtot(Ttod(tt))) Return This.n2s(nDaynr)+"_"+This.n2s(nSecs,3) *--------------------------------------------------- Procedure s2t(c) *-- dn 15/06/06 Local c, o, N, i, l, cCRS cDate=Getwordnum(c,1,"_") cTime=Getwordnum(c,2,"_") dDate={^1980-01-01}+This.s2n(cDate) tDt=Dtot(dDate)+This.s2n(cTime) Return tDt *--------------------------------------------------- broj u string Procedure n2s(tNR, nLen) Local nMod, numdat, sl nMod=Len(This.trnN2S) numdat=tNR sl="" Do While numdat>0 ns=numdat%nMod sl=Substr(This.trnN2S,ns+1,1)+sl numdat=Int(numdat/nMod) Enddo If !Empty(nLen) And Len(sl)<nLen sl=Padl(sl, nLen, Left(This.trnN2S,1)) Endif Retu sl *--------------------------------------------------- string u broj Procedure s2n(c) Local nMod, N nMod=Len(This.trnN2S) N=0 For i= 1 To Len(c) N = N*nMod+Atc(Substr(c, i, 1), This.trnN2S) -1 Endfor Retu N EnddefineAdding more characters to the coding string may actually shorten the result even more - like adding lowercase, accented etc. Also, using fixed lengths for parts may remove the underscore (as the lengths of the date and seconds part will be known in advance). Initially, my coding string was much shorter, because I was also using this to generate filenames - had an old digital camera which didn't have continuous counting, so every time I wipe the card it starts from img_0001.jpg, but at least it stored the datetimes somewhere, so I dug that out and renamed the files as per those internal timestamps. The result had to conform to file naming conventions, so I couldn't add lowercase or punctuation to it - had just uppercase and digits, and the resulting string was, guess what, 8 bytes :). But at least it was printable.