|From: Keith Parks <emkxp01@mtcc.demon.co.uk>

|Subject: [PATCH] adding SYS_TIME just for fun.
|
|Hi,
|
|Whilst I was playing round with the European dates patch I noticed the sysfunc()
|that allows you to do :-
|
|create table test ( da date);
|insert into test values (SYS_DATE);
|
|and have the current system date inserted.
|
|So I thought it would be nice to have the SYS_TIME facility too.
|
|I've cloned the function and changed a few things and there you have it,
|you can now do:
|
|create table test2 ( ti time);
|insert into test2 values (SYS_TIME);
This commit is contained in:
Marc G. Fournier 1997-01-26 17:28:48 +00:00
parent 1d8a696fd5
commit 427a964c30
1 changed files with 16 additions and 0 deletions

View File

@ -45,10 +45,26 @@ static char *Sysfunc_system_date(void)
return &buf[0];
}
static char *Sysfunc_system_time(void)
{
time_t cur_time_secs;
struct tm *cur_time_expanded;
static char buf[10]; /* Just for safety, y'understand... */
time(&cur_time_secs);
cur_time_expanded = localtime(&cur_time_secs);
sprintf(buf, "%2.2d:%2.2d:%2.2d", cur_time_expanded->tm_hour,
cur_time_expanded->tm_min, cur_time_expanded->tm_sec);
return &buf[0];
}
char *SystemFunctionHandler(char *funct)
{
if (!strcmp(funct, "SYS_DATE"))
return Sysfunc_system_date();
if (!strcmp(funct, "SYS_TIME"))
return Sysfunc_system_time();
return "*unknown function*";
}