From: Clint Adams <clint@zsh.org>
To: zsh-workers@sunsite.dk
Subject: PATCH: $SECS
Date: Sun, 28 Sep 2003 12:19:59 -0400 [thread overview]
Message-ID: <20030928161959.GA29645@acolyte.scowler.net> (raw)
In-Reply-To: <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))
+ );
}
/**/
next prev parent reply other threads:[~2003-09-28 16:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-19 2:06 PATCH: langinfo module Clint Adams
2002-04-30 18:52 ` PATCH: strftime builtin Clint Adams
2002-05-01 9:38 ` Peter Stephenson
2002-05-26 21:58 ` Clint Adams
2002-05-27 5:05 ` Borsenkow Andrej
[not found] ` <23146.1064741224@athlon>
2003-09-28 16:19 ` Clint Adams [this message]
2003-09-28 17:30 ` PATCH: $SECS Bart Schaefer
2003-09-28 18:05 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030928161959.GA29645@acolyte.scowler.net \
--to=clint@zsh.org \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).