Update of /cvsroot/monetdb/MonetDB5/src/modules/atoms
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10225/src/modules/atoms

Modified Files:
      Tag: MonetDB_5-4
        mtime.mx 
Log Message:
adding some missing time conversion functions


Index: mtime.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/atoms/mtime.mx,v
retrieving revision 1.106.2.6
retrieving revision 1.106.2.7
diff -u -d -r1.106.2.6 -r1.106.2.7
--- mtime.mx    7 Feb 2008 08:23:26 -0000       1.106.2.6
+++ mtime.mx    11 Feb 2008 21:41:00 -0000      1.106.2.7
@@ -323,9 +323,12 @@
 command epoch{unsafe}():timestamp
 address MTIMEepoch
 comment "unix-time (epoch) support: seconds since the Unix epoch";
-command epoch{unsafe}(t:timestamp):lng 
-address MTIMEepoch2lng
+command epoch(t:timestamp):int 
+address MTIMEepoch2int
 comment "unix-time (epoch) support: seconds since epoch";
+command epoch(t:int):timestamp 
+address MTIMEtimestamp
+comment "convert seconds since epoch into a timestamp";
 
 @:compareGrp(timestamp)@
 
@@ -804,6 +807,8 @@
 command timestamp(s:str):timestamp address MTIMEtimestamp_fromstr;
 command timestamp(t:timestamp):timestamp address MTIMEtimestamp2timestamp;
 command timestamp(d:date) :timestamp address MTIMEtimestamp_create_from_date;
+command timestamp(secs:int):timestamp address MTIMEtimestamp;
+command timestamp(secs:lng):timestamp address MTIMEtimestamp_lng;
 
 command daytime(s:str):daytime address MTIMEdaytime_fromstr;
 command daytime(d:daytime):daytime address MTIMEdaytime2daytime;
@@ -1036,8 +1041,9 @@
 mtime_export str MTIMEdaytime3(daytime *ret, int *h, int *m, int *s);
 mtime_export str MTIMEunix_epoch(timestamp *ret);
 mtime_export str MTIMEepoch(timestamp *ret);
-mtime_export str MTIMEepoch2lng(lng *ret, timestamp *t);
+mtime_export str MTIMEepoch2int(int *res, timestamp *ts);
 mtime_export str MTIMEtimestamp(timestamp *ret, int *sec);
+mtime_export str MTIMEtimestamp_lng(timestamp *ret, lng *sec);
 mtime_export str MTIMEruleDef0(rule *ret, int *m, int *d, int *w, int *h, int 
*mint);
 mtime_export str MTIMEruleDef1(rule *ret, int *m, str *dnme, int *w, int *h, 
int *mint);
 mtime_export str MTIMEruleDef2(rule *ret, int *m, str *dnme, int *w, int 
*mint);
@@ -3690,19 +3696,19 @@
 
        /* convert number of seconds into a timestamp */
        if ((e = MTIMEunix_epoch(&ts)) == MAL_SUCCEED)
-                       e = MTIMEtimestamp_add(ret, &ts, &t);
-       return (e);
+               e = MTIMEtimestamp_add(ret, &ts, &t);
+       return e;
 }
 
 str
-MTIMEepoch2lng(lng *ret, timestamp *t)
+MTIMEepoch2int(int *ret, timestamp *t)
 {
        timestamp e;
        lng v;
 
        MTIMEunix_epoch(&e);
-       timestamp_diff(&v, &e, t);
-       *ret = v / 1000;
+       timestamp_diff(&v, t, &e);
+       *ret = (int)(v / 1000);
        return MAL_SUCCEED;
 }
 
@@ -3718,6 +3724,17 @@
 }
 
 str
+MTIMEtimestamp_lng(timestamp *ret, lng *sec)
+{
+       timestamp e;
+       lng l = *sec * 1000;
+
+       MTIMEunix_epoch(&e);
+       timestamp_add(ret, &e, &l);
+       return MAL_SUCCEED;
+}
+
+str
 MTIMEruleDef0(rule *ret, int *m, int *d, int *w, int *h, int *mint)
 {
        int d0 = 60 * *h;


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to