Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Greg Green
  Where is Greg Green?
 
 Georgia - United States
 Greg Green
 To: Dan Baker
  Where is Dan Baker?
 Effort of the Poconos
 Pennsylvania - United States
 Dan Baker
 Tags
Subject: RE: How does SCX TimeStamp get computed?
Thread ID: 416100 Message ID: 416109 # Views: 47 # Ratings: 3
Version: Visual FoxPro 9 Category: Forms
Date: Sunday, December 21, 2014 9:19:59 PM         
   


> Foxites,
>
> I want to have some version control for the objects in my form and
> I thought it best to use the timestamp and code in the SCX as the reference.
>
> What I figure on doing is have the main.prg of MyProject, do a COPY FILE
> of the SCX into MyProjectFormBackUp.DBF.
>
> Then I would use this new file to extract the code and timestamp information
> from the copied SCX.  Is this procedure safe and sound practice?
>
> And I can't figure out how SCX calculates the TimeStamp.  It looks like the timestamp
> is based on the form's creation Datetime. It also appears the TimeStamp for the Data Environment
> object remains constant and the Form object is timestamped with every new save of the form. 
> Any control that is changed in the current design time session gets a new timestamp.
>
> Appreciate the help.  Dan B.

I have looked at this for determining which object changed in the past. I found that VFP9 did not always update the timestamp field so it was not reliable for my use. But the code below will set or return the timestamp value (I believe I got it from Calvin Hsia blog).

*=======================================================
* Returns a FOX system file timestamp 
* from a date time value, any data type
*
*=======================================================
FUNCTION GKKSetFoxTimeStamp
LPARAMETER tvDateTime
*-------------------------------------------------------
* Default to current datetime
*-------------------------------------------------------
LOCAL ltDateTime, lvFoxTimeStamp, lvTemp
ltDateTime = CTOT(TRANSFORM(tvDateTime))
IF EMPTY(ltDateTime)
   ltDateTime = DATETIME()
ENDIF
*-------------------------------------------------------
* bits 4-0, seconds in two-second increments
*-------------------------------------------------------
lvTemp = SEC(ltDateTime) / 2
lvFoxTimeStamp = PADL(RIGHT(fIntToBin(lvTemp),5),5,"0")
*-------------------------------------------------------
* bits 10-5, minutes
*-------------------------------------------------------
lvTemp = MINUTE(ltDateTime)
lvFoxTimeStamp = PADL(RIGHT(fIntToBin(lvTemp),6),6,"0") + lvFoxTimeStamp
*-------------------------------------------------------
* bits 15-11, hours
*-------------------------------------------------------
lvTemp = HOUR(ltDateTime)
lvFoxTimeStamp = PADL(RIGHT(fIntToBin(lvTemp),5),5,"0") + lvFoxTimeStamp
*-------------------------------------------------------
* bits 20-16, days
*-------------------------------------------------------
lvTemp = DAY(ltDateTime)
lvFoxTimeStamp = PADL(RIGHT(fIntToBin(lvTemp),5),5,"0") + lvFoxTimeStamp
*-------------------------------------------------------
* bits 24-21, months
*-------------------------------------------------------
lvTemp = MONTH(ltDateTime)
lvFoxTimeStamp = PADL(RIGHT(fIntToBin(lvTemp),4),4,"0") + lvFoxTimeStamp
*-------------------------------------------------------
* bits 31-25, years with a 1980 offset
*-------------------------------------------------------
lvTemp = YEAR(ltDateTime)-1980
lvFoxTimeStamp = PADL(RIGHT(fIntToBin(lvTemp),7),7,"0") + lvFoxTimeStamp
lvFoxTimeStamp = fBinToInt(lvFoxTimeStamp)
RETURN lvFoxTimeStamp
ENDFUNC


*=======================================================
* Returns a binary form of an integer
*
FUNCTION fIntToBin
LPARAMETERS tnInteger
LOCAL lnInteger,lcBinary,lnDivisor,lnCount
IF EMPTY(tnInteger)
	RETURN "0"
ENDIF
lnInteger=INT(tnInteger)
lcBinary=""
FOR lnCount = 31 TO 0 STEP -1
	lnDivisor=2^lnCount
	IF lnDivisor>lnInteger
		lcBinary=lcBinary+"0"
		LOOP
	ENDIF
	lcBinary=lcBinary+IIF((lnInteger/lnDivisor)>0,"1","0")
	lnInteger=INT(lnInteger-lnDivisor)
ENDFOR
RETURN lcBinary
ENDFUNC


*=======================================================
* Returns an integer form of binary data
*
FUNCTION fBinToInt
LPARAMETERS tcBinary
LOCAL lcInteger,lnInteger,lnCount,lnStrLen
IF EMPTY(tcBinary)
	RETURN 0
ENDIF
lnStrLen=LEN(tcBinary)
lnInteger=0
FOR lnCount = 0 TO (lnStrLen-1)
	IF SUBSTR(tcBinary,lnStrLen-lnCount,1)=="1"
		lnInteger=lnInteger+2^lnCount
	ENDIF
ENDFOR
RETURN INT(lnInteger)
ENDFUNC


For the other function:

*=======================================================
* Returns a readable string version of a Fox system 
* timestamp, using current date settings
*=======================================================
FUNCTION GKKGetFoxTimeStamp
LPARAMETER tiStamp 
LOCAL lnYearoffset,lcYear,lcMonth,lcDay,lcHour,lcMinute,lcSecond
IF EMPTY(tiStamp) OR TYPE("tiStamp") # "N"  
   RETURN ""
ENDIF
lnYearoffset = BITRSHIFT(tiStamp,25)
lcYear   = STR(1980 + lnYearoffset)
lcMonth  = STR(BITRSHIFT(tiStamp,21) % 2^4)
lcDay    = STR(BITRSHIFT(tiStamp,16) % 2^5)
lcHour   = STR(BITRSHIFT(tiStamp,11) % 2^5)
lcMinute = STR(BITRSHIFT(tiStamp,5) % 2^6)
lcSecond = STR(BITLSHIFT(tiStamp%2^5,1))
RETURN TTOC({^&lcYear./&lcMonth./&lcDay. &lcHour.:&lcMinute.:&lcSecond.})	
ENDFUNC


ENTIRE THREAD

How does SCX TimeStamp get computed? Posted by Dan Baker @ 12/21/2014 4:37:08 PM
RE: How does SCX TimeStamp get computed? Posted by Pete Sass @ 12/21/2014 6:59:56 PM
RE: How does SCX TimeStamp get computed? Posted by Dan Baker @ 12/21/2014 11:41:09 PM
RE: How does SCX TimeStamp get computed? Posted by Pete Sass @ 12/22/2014 12:09:50 AM
RE: How does SCX TimeStamp get computed? Posted by Fernando Bozzo @ 12/21/2014 9:08:48 PM
RE: How does SCX TimeStamp get computed? Posted by Dan Baker @ 12/22/2014 12:45:44 AM
RE: How does SCX TimeStamp get computed? Posted by Greg Green @ 12/21/2014 9:19:59 PM
RE: How does SCX TimeStamp get computed? Posted by Dan Baker @ 12/22/2014 12:52:17 AM
RE: How does SCX TimeStamp get computed? Posted by Greg Green @ 12/22/2014 7:44:39 AM
RE: How does SCX TimeStamp get computed? Posted by Dan Baker @ 12/23/2014 12:11:44 AM
RE: How does SCX TimeStamp get computed? Posted by Jun Tangunan @ 12/22/2014 12:54:11 AM
RE: How does SCX TimeStamp get computed? Posted by Mustapha Bihmouten @ 12/22/2014 2:59:24 PM
RE: How does SCX TimeStamp get computed? Posted by Dan Baker @ 12/22/2014 3:10:42 PM