[pure-lang-svn] SF.net SVN: pure-lang: [425] pure/trunk/examples/libor/date.pure
Status: Beta
Brought to you by:
agraef
From: <ye...@us...> - 2008-07-08 20:38:42
|
Revision: 425 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=425&view=rev Author: yes Date: 2008-07-08 13:38:51 -0700 (Tue, 08 Jul 2008) Log Message: ----------- added 'timex' function discussed earlier on pure-lang-users list Modified Paths: -------------- pure/trunk/examples/libor/date.pure Modified: pure/trunk/examples/libor/date.pure =================================================================== --- pure/trunk/examples/libor/date.pure 2008-07-08 17:37:56 UTC (rev 424) +++ pure/trunk/examples/libor/date.pure 2008-07-08 20:38:51 UTC (rev 425) @@ -24,13 +24,17 @@ def fullmoon = 1213810200;// 18th June 2008, 17:30, full moon in posix seconds def venussyn = 50450688;// duration of the Venus synodic cycle def venusinf = 1187409600;// 18th August 2007, 4am Venus inferior conjunction - + +/******************************************************************************/ +// first a couple of functions generally useful in Pure: +// timer function: (timex (id (foo arg))) returns cputime, value of (foo arg) +timex fn = (clock-t)/CLOCKS_PER_SEC $ res when t = clock; res = fn end; + /* extended mod operator to work on doubles, so that int, bigint and double times can be conveniently used */ x::double mod y::int = (x - intx) + (intx mod y) when intx = (int x) end; // mod of a double - -// can also use secsnow = gettimeofday mod secsinday; double for more accuracy +/******************************************************************************/ secsnow = time mod secsinday; // int seconds since midnight // either mayan or julian posix epoch (plus posix seconds), gives a double mjday This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |