Converting Unix epoch format to normal date for filePro

Kenneth Brody kenbrody at spamcop.net
Thu Jul 22 10:37:01 PDT 2010


On 7/22/2010 1:08 PM, Larry Hoover wrote:
> When you take a Unix epoch formatted date such as: 1240432776, you can
> convert it to a filePro friendly date such as 04/22/09 in Linux with the
> command:
> date +%D --date "Jan 1, 1970 00:00:00 +0000 + 1240432776 seconds"
> I can't seem to find a way to do this in SCO Unix Openserver.  The date
> command is different than in Linux.  Does anyone know offhand of a
> compatible SCO Unix command to do this, or some way in filePro?

How accurate do you need it?  Do you need leap-seconds taken into account?

There are 3,600 seconds in an hour, and 86,400 seconds in a day.  Just use 
filePro date and time math to go from there.

========
@keyT::input popup ti(10,.0) "Enter seconds since epoch☺ ":
:ti = "":end:
::declare Epoch(10,mdyy/) ; Epoch = "01/01/1970":
::dt(10,mdyy/) = Epoch + int(ti/"86400"):
::tm(8,time) = mod(ti,"86400") / "3600":
::mesgbox ti < "equals" < dt < tm:
::end:
========

You will probably have to adjust for timezones, however.

-- 
Kenneth Brody


More information about the Filepro-list mailing list