cvs: /php3/functions parsedate.y /php3 Makefile.in cvsusers /php3/functions basic_functions.c datetime.c datetime.h
| From: | andrey | Date: | Mon, 12 Jul 1999 11:56:30 +0000 |
| Subject: | cvs: /php3/functions parsedate.y /php3 Makefile.in cvsusers /php3/functions basic_functions.c datetime.c datetime.h | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-8394@lists.php.net to get a copy of this message | ||
andrey Mon Jul 12 11:56:30 1999 EDT
Added files:
/php3/functions parsedate.y
Modified files:
/php3 Makefile.in cvsusers
/php3/functions basic_functions.c datetime.c datetime.h
Log:
Added strtotime() function from Nick Sayer <nsayer@quack.kfu.com>.
Needs testing and docs. I had to hack parsedate.y a bit to get it
to compile, so bison gurus please check it out.
Index: php3/Makefile.in
diff -u php3/Makefile.in:1.337 php3/Makefile.in:1.338
--- php3/Makefile.in:1.337 Sat Jul 3 01:40:20 1999
+++ php3/Makefile.in Mon Jul 12 11:56:30 1999
@@ -24,7 +24,7 @@
# +----------------------------------------------------------------------+
#
-# $Id: Makefile.in,v 1.337 1999/07/03 05:40:20 bjh Exp $
+# $Id: Makefile.in,v 1.338 1999/07/12 15:56:30 andrey Exp $
#
prefix = @prefix@
@@ -103,7 +103,7 @@
functions/yp.c functions/dba.c functions/dba_gdbm.c \
functions/dba_dbm.c functions/dba_ndbm.c functions/dba_cdb.c \
functions/mcrypt.c functions/dba_db2.c functions/mhash.c \
- functions/pcre.c functions/posix.c
+ functions/pcre.c functions/posix.c functions/parsedate.c
FUNCTIONS = $(FUNCTIONS_SOURCE:.c=.o)
@@ -142,6 +142,9 @@
functions/ifx.c: functions/ifx.ec
@IFX_C_MAKE@
+functions/parsedate.h functions/parsedate.c: functions/parsedate.y
+ bison -v -d functions/parsedate.y -o functions/parsedate.c
+
language-parser.tab.h language-parser.tab.c: $(srcdir)/language-parser.y
bison -p php -v -d $(srcdir)/language-parser.y -o language-parser.tab.c
@@ -234,7 +237,7 @@
@bn=
echo $@ | sed -e 's#functions/##'; test -f $@ || \
(test "$@" != "$$bn" && test -f "$$bn" && mv $$bn
$@)
-parser-scanner: configuration-parser.tab.c configuration-scanner.c language-parser.tab.c
language-scanner.c
+parser-scanner: configuration-parser.tab.c configuration-scanner.c language-parser.tab.c
language-scanner.c functions/parsedate.c
depend: parser-scanner
$(CC) $(CFLAGS) -MM $(SOURCE) | perl -pe 's|regex/regex.h||;' > Makefile.depend
Index: php3/cvsusers
diff -u php3/cvsusers:1.57 php3/cvsusers:1.58
--- php3/cvsusers:1.57 Mon Jul 12 11:16:20 1999
+++ php3/cvsusers Mon Jul 12 11:56:30 1999
@@ -61,7 +61,7 @@
swilliam Steve Williams swilliam@empress.com Empress support in unified ODBC
sas Sascha Schumann sas@schell.de Various tweaks
aka Amalesh Kempf aka@bigfoot.de Documentation
-andrey Andrey Zmievski zmievski@ispi.net WDDX and bug fixes
+andrey Andrey Zmievski zmievski@ispi.net WDDX, PCRE, misc functions
alex Alex Plotnick shrike@netaxs.com gettext module
affinity Donald C. Sumbry][ sumbry@affinity.net Documentation
timothy Timothy Whitfield timothy@ametro.net Cybercash module
Index: php3/functions/basic_functions.c
diff -u php3/functions/basic_functions.c:1.272 php3/functions/basic_functions.c:1.273
--- php3/functions/basic_functions.c:1.272 Mon Jul 12 07:01:19 1999
+++ php3/functions/basic_functions.c Mon Jul 12 11:56:30 1999
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.272 1999/07/12 11:01:19 sas Exp $ */
+/* $Id: basic_functions.c,v 1.273 1999/07/12 15:56:30 andrey Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
@@ -136,6 +136,7 @@
{"gmdate", php3_gmdate, NULL},
{"getdate", php3_getdate, NULL},
{"checkdate", php3_checkdate, NULL},
+ {"strtotime", php3_strtotime, NULL},
{"chr", php3_chr, NULL},
{"ord", php3_ord, NULL},
{"flush", php3_flush, NULL},
Index: php3/functions/datetime.c
diff -u php3/functions/datetime.c:1.66 php3/functions/datetime.c:1.67
--- php3/functions/datetime.c:1.66 Tue Jun 22 17:57:40 1999
+++ php3/functions/datetime.c Mon Jul 12 11:56:30 1999
@@ -30,7 +30,7 @@
*/
-/* $Id: datetime.c,v 1.66 1999/06/22 21:57:40 sas Exp $ */
+/* $Id: datetime.c,v 1.67 1999/07/12 15:56:30 andrey Exp $ */
#ifdef THREAD_SAFE
@@ -79,6 +79,8 @@
#define isleap(year) (((year%4) == 0 && (year%100)!=0) || (year%400)==0)
+extern PHPAPI time_t parsedate(char *p, struct timeval *now);
+
/* {{{ proto int time(void)
Return current UNIX timestamp */
void php3_time(INTERNAL_FUNCTION_PARAMETERS)
@@ -594,6 +596,33 @@
}
/* }}} */
#endif
+
+
+/* {{{ proto int strtotime(string time, int now) */
+void php3_strtotime(INTERNAL_FUNCTION_PARAMETERS)
+{
+ pval *timep, *nowp;
+ int ac;
+ struct timeval tv;
+
+ ac = ARG_COUNT(ht);
+
+ if (ac < 1 || ac > 2 || getParameters(ht, ac, &timep, &nowp)==FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string(timep);
+ if (ac == 2) {
+ convert_to_long(nowp);
+ tv.tv_sec = nowp->value.lval;
+ tv.tv_usec = 0;
+ RETURN_LONG(parsedate(timep->value.str.val, &tv));
+ } else
+ RETURN_LONG(parsedate(timep->value.str.val, NULL));
+}
+/* }}} */
+
+
/*
* Local variables:
* tab-width: 4
Index: php3/functions/datetime.h
diff -u php3/functions/datetime.h:1.14 php3/functions/datetime.h:1.15
--- php3/functions/datetime.h:1.14 Sun Jun 20 13:14:05 1999
+++ php3/functions/datetime.h Mon Jul 12 11:56:30 1999
@@ -29,7 +29,7 @@
*/
-/* $Id: datetime.h,v 1.14 1999/06/20 17:14:05 jim Exp $ */
+/* $Id: datetime.h,v 1.15 1999/07/12 15:56:30 andrey Exp $ */
#ifndef _DATETIME_H
#define _DATETIME_H
@@ -44,6 +44,8 @@
#if HAVE_STRFTIME
extern void php3_strftime(INTERNAL_FUNCTION_PARAMETERS);
#endif
+extern void php3_strtotime(INTERNAL_FUNCTION_PARAMETERS);
+
extern char *php3_std_date(time_t t);
void _php3_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm);