Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Dan Baker
  Where is Dan Baker?
 Effort of the Poconos
 Pennsylvania - United States
 Dan Baker
 To: Greg Green
  Where is Greg Green?
 
 Georgia - United States
 Greg Green
 Tags
Subject: RE: How does SCX TimeStamp get computed?
Thread ID: 416100 Message ID: 416118 # Views: 36 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Monday, December 22, 2014 12:52:17 AM         
   


Hey Greg,

Just what I needed. Tested the last function and it solves the mystery.

Do you happen to work in the Mobility side of SAP? I have a new research
study coming up for the telecom operator side of that story.

Cheers,


Dan B.


>
>
> *=======================================================
> * 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