Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sys(2015) -- unique procedure name question
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00347389
Message ID:
00355386
Views:
31
>Thanks very much, Frank. Clever how you figured all that out.

Thanks for the compliment. For me it was both a neccesary thing to do but also a challenge, could I crack it?

But I'm curious. Doesn't your routine convert a Sys(2105) value to its corresponding DateTime? I need something to go the other way. That is, given an arbitrary DateTime, I need the corresponding output of Sys(2015). Do you have that code as well?

It indeed does, but there is a little program which will do the opposite thing, convert a sys(2015) string from a datetime (with millisecs if needed)

hth,
Frank
LPARAMETERS tDateTime,nMilliSeconds

*Routine to convert a datetime (with optional milliseconds) to the sys(2015) value

LOCAL nMilliSecs,nDays,cBase36,cSys2016

* If no milliseconds are given, use the default value of 0

IF VARTYPE(nMilliSeconds)<>'N'
	nMilliSeconds=0
ENDIF

*The total millisecs since midnight
nMilliSecs=(HOUR(tDateTime)*3600+MINUTE(tDateTime)*60+SEC(tDateTime))*1000+nMilliSeconds

*The total days since Jan 1st '00 (Where the total days in a (Full) year is 367)
nDays=TTOD(tDateTime)-DATE(YEAR(tDateTime),1,1)+1+MOD(YEAR(tDateTime),100)*367

*The table used to 'display' the right value in the string.
*The sys2015 uses a Base36, where 0=0 and Z=35
cBase36='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

*Make the resultstring empty
cSys2015=''

*We are going to construct the sys2015 string from back to front.

*First the total millisecs
FOR nCounter=1 TO 6
	*The string is the mod value +1, because 0 means char at location 1 etc.
	cSys2015=SUBSTR(cBase36,MOD(nMilliSecs,36)+1,1)+cSys2015
	nMilliSecs=INT(nMilliSecs/36)
ENDFOR

*Second the days since Jan 1st '00
FOR nCounter=1 TO 3
	cSys2015=SUBSTR(cBase36,MOD(nDays,36)+1,1)+cSys2015
	nDays=INT(nDays/36)
ENDFOR

*Third, the Underscore
cSys2015='_'+cSys2015

*Return the string
RETURN cSys2015
Frank Camp
Previous
Reply
Map
View

Click here to load this message in the networking platform