1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-12 01:11:27 +02:00

19151: Src/Modules/datetime.c: add $SECS parameter for seconds since epoch.

This commit is contained in:
Clint Adams 2003-09-28 16:26:58 +00:00
parent 0d82bda526
commit 95030cd034
2 changed files with 19 additions and 1 deletions

View file

@ -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> 2003-09-25 Peter Stephenson <pws@csr.com>
* unposted: Completion/Unix/Command/_perforce: suggested by * unposted: Completion/Unix/Command/_perforce: suggested by

View file

@ -63,10 +63,21 @@ bin_strftime(char *nam, char **argv, Options ops, int func)
return 0; return 0;
} }
static zlong
getcurrentsecs()
{
return (zlong) time(NULL);
}
static struct builtin bintab[] = { static struct builtin bintab[] = {
BUILTIN("strftime", 0, bin_strftime, 2, 2, 0, NULL, NULL), 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 int
setup_(Module m) setup_(Module m)
@ -78,7 +89,9 @@ setup_(Module m)
int int
boot_(Module m) 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))
);
} }
/**/ /**/