Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Another unique file name ?
Message
De
25/04/2001 10:37:11
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00499538
Message ID:
00499581
Vues:
30
>I like SYS(3) and SUBSTR(SYS(2015),3,10), but I want a file format that the user can understand. Im thinking "date"+"time"+"milliseconds".
>date length = 6
>time length = 4
>millisec length = 2
>
>How do I get the milliseconds ?
>
>Thanks!

Adam,
Format length is 17 including century (8+6+3). However you could drop century part + use days from Jan 1st to squeeze it to 14 chars (further could squeeze but would be unreadable again:).
I don't remember from whom I got the base code (thanks to whoever s/he was). Here is a modified version of code :
? Sys2015AsTimeString(sys(2015))

function Sys2015AsTimeString
Lparameters tcString, tnCentury, tnRollover
tnCentury=iif(type('tnCentury')#'N',19,tnCentury)
tnRollover=iif(type('tnRollover')#'N',50,tnRollover)
Local lnDay,lnYear, lnMillisecs, lnVal, ix, lnHoursMinsSecs, lnHours, lnMins, lnSecs

lnDay = 0
lnMillisecs = 0
For ix = 1 to 9
  tcString = SUBSTR(tcString,2)
  lnVal=ASC(tcString)-IIF(ISDIGIT(tcString),48,55)
  If ix < 4
    lnDay = lnDay + lnVal*36^(3-ix)
  Else
    lnMillisecs = lnMillisecs + lnVal*36^(9-ix)
  Endif
Endfor
*In the SYS(2015) world, every year has 367 days
lnYear=INT(lnDay/367)

*Add the right century to this year, because SYS(2015) only has years 0-99
*Strip the year off, so you only have the days since Jan 1st
lnYear=tnCentury*100+IIF(lnYear<tnRollover or lnYear=0,100,0)+lnYear
lnDay=lnDay%367
* lNDay must be substracted by 1 because lnDay=1 is Jan 1st, not day 0
lnHoursMinsSecs=int(lnMillisecs/1000)
lnHours=int(lnHoursMinsSecs/(60*60))
lnMins=int(lnHoursMinsSecs%(60*60)/60)
lnSecs=lnHoursMinsSecs%(60*60)%60
Return dtos(eval('{^'+str(lnYear,4)+'/1/1}')+lnDay-1)+;
  padl(lnHours,2,'0')+padl(lnMins,2,'0')+padl(lnSecs,2,'0')+padl(lnMillisecs%1000,3,'0')
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform