[genius] Mon Nov 07 00:28:58 2011 Jiri (George) Lebl <jirka 5z com>



commit 7295cc7ede7f0a339d48a699ab70ac9dcb9468ea
Author: Jiri (George) Lebl <jirka 5z com>
Date:   Mon Nov 7 00:29:02 2011 -0600

    Mon Nov 07 00:28:58 2011  Jiri (George) Lebl <jirka 5z com>
    
    	* src/funclib.c, help/C/gel-function-list.xml:  Add CurrentTime
    	  to return the current UNIX time

 ChangeLog                    |    5 +++++
 NEWS                         |    1 +
 help/C/gel-function-list.xml |    8 ++++++++
 src/funclib.c                |   17 +++++++++++++++++
 4 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 95e2262..53a8729 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Nov 07 00:28:58 2011  Jiri (George) Lebl <jirka 5z com>
+
+	* src/funclib.c, help/C/gel-function-list.xml:  Add CurrentTime
+	  to return the current UNIX time 
+
 Mon Sep 26 17:39:27 2011  Jiri (George) Lebl <jirka 5z com>
 
 	* configure.in, lib/Makefile.am, lib/communtative_algebra/Makefile.am,
diff --git a/NEWS b/NEWS
index c2f874b..bbca849 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ Changes to 1.0.15
 
 * New functions MacaulayRep, MacaulayLowerOperator, MacaulayBound
 * FIXME: TEST AND DOCUMENT the above
+* New functions CurrentTime (DOCUMENTED)
 
 Changes to 1.0.14
 
diff --git a/help/C/gel-function-list.xml b/help/C/gel-function-list.xml
index 6dffa38..6825c88 100644
--- a/help/C/gel-function-list.xml
+++ b/help/C/gel-function-list.xml
@@ -280,6 +280,14 @@ is called inside a block that was evaluated using modular arithmetic (using <lit
          </listitem>
         </varlistentry>
 
+        <varlistentry id="gel-function-CurrentTime">
+         <term>CurrentTime</term>
+         <listitem>
+          <synopsis>CurrentTime</synopsis>
+          <para>Returns the current UNIX time with microsecond precision as a floating point number.  That is, returns the number of seconds since January 1st 1970.</para>
+         </listitem>
+        </varlistentry>
+
         <varlistentry id="gel-function-display">
          <term>display</term>
          <listitem>
diff --git a/src/funclib.c b/src/funclib.c
index ec0f376..2d0c18d 100644
--- a/src/funclib.c
+++ b/src/funclib.c
@@ -364,6 +364,21 @@ false_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
 	return gel_makenum_bool (0);
 }
 
+static GelETree *
+CurrentTime_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
+{
+	mpw_t tm;
+	struct timeval tv;
+
+	mpw_init (tm);
+	gettimeofday (&tv, NULL);
+	mpw_set_ui (tm, tv.tv_usec);
+	mpw_make_float (tm);
+	mpw_div_ui (tm, tm, 1000000);
+	mpw_add_ui (tm, tm, tv.tv_sec);
+	return gel_makenum_use (tm);
+}
+
 /*sin function*/
 static GelETree *
 IntegerFromBoolean_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
@@ -6297,6 +6312,8 @@ gel_funclib_addall(void)
 	FUNC (false, 0, "", "basic", N_("The false boolean value"));
 	ALIAS (False, 0, false);
 
+	FUNC (CurrentTime, 0, "", "basic", N_("Unix time in seconds as a floating point number"));
+
 	/* FIXME: TRUE, FALSE aliases can't be done with the macros in funclibhelper.cP! */
 	d_addfunc (d_makebifunc (d_intern ("TRUE"), true_op, 0));
 	gel_add_alias ("true", "TRUE");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]