Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: $SECS
- X-seq: zsh-workers 19151
- From: Clint Adams <clint@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: $SECS
- Date: Sun, 28 Sep 2003 12:19:59 -0400
- In-reply-to: <23146.1064741224@athlon>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20020430185259.GA2825@xxxxxxxx> <21763.1020245894@xxxxxxx> <20020526215840.GA15122@xxxxxxxx> <23146.1064741224@athlon>
> Any chance we could have some documentation for this? I take it that the
> first argument is the strftime format and the second is the number of
> seconds since the epoch. Would be nice if the second argument was
> optional and defaulted to the current time.
With the following patch, you can do
strftime "%d-%m-%y" $SECS
Is it worth having the second argument be optional? Is SECS too generic
a name?
Index: Src/Modules/datetime.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/datetime.c,v
retrieving revision 1.3
diff -u -r1.3 datetime.c
--- Src/Modules/datetime.c 27 Aug 2002 21:10:34 -0000 1.3
+++ Src/Modules/datetime.c 28 Sep 2003 16:16:56 -0000
@@ -63,10 +63,21 @@
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 @@
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))
+ );
}
/**/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author