about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2003-09-28 16:26:58 +0000
committerClint Adams <clint@users.sourceforge.net>2003-09-28 16:26:58 +0000
commit95030cd0346623e1a0167abea33c42c3322cf37a (patch)
treeb99feb441f690b15decd2313950de463c3e2a585
parent0d82bda52640ede8960ae5b4bb5d00eb02e90108 (diff)
downloadzsh-95030cd0346623e1a0167abea33c42c3322cf37a.tar.gz
zsh-95030cd0346623e1a0167abea33c42c3322cf37a.tar.xz
zsh-95030cd0346623e1a0167abea33c42c3322cf37a.zip
19151: Src/Modules/datetime.c: add $SECS parameter for seconds since epoch.
-rw-r--r--ChangeLog5
-rw-r--r--Src/Modules/datetime.c15
2 files changed, 19 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0254f783c..6196715fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-09-28  Clint Adams  <clint@zsh.org>
+
+	* 19151: Src/Modules/datetime.c: add $SECS parameter for
+	seconds since epoch.
+
 2003-09-25  Peter Stephenson  <pws@csr.com>
 
 	* unposted: Completion/Unix/Command/_perforce: suggested by
diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c
index e43f12b24..d10274f0d 100644
--- a/Src/Modules/datetime.c
+++ b/Src/Modules/datetime.c
@@ -63,10 +63,21 @@ bin_strftime(char *nam, char **argv, Options ops, int func)
     return 0;
 }
 
+static zlong
+getcurrentsecs()
+{
+    return (zlong) time(NULL);
+}
+
 static struct builtin bintab[] = {
     BUILTIN("strftime",    0, bin_strftime,    2,   2, 0, NULL, NULL),
 };
 
+static struct paramdef patab[] = {
+    PARAMDEF("SECS", PM_INTEGER|PM_SPECIAL|PM_READONLY,
+		    NULL, NULL, &getcurrentsecs, NULL),
+};
+
 /**/
 int
 setup_(Module m)
@@ -78,7 +89,9 @@ setup_(Module m)
 int
 boot_(Module m)
 {
-    return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+    return !(addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab)) |
+	     addparamdefs(m->nam, patab, sizeof(patab)/sizeof(*patab))
+	    );
 }
 
 /**/