cvs: /php4/ext/standard parsedate.y /php4/ext/standard Makefile.am basic_functions.c datetime.c datetime.h

From: Date: Fri, 23 Jul 1999 19:51:27 +0000
Subject: cvs: /php4/ext/standard parsedate.y /php4/ext/standard Makefile.am basic_functions.c datetime.c datetime.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-2638@lists.php.net to get a copy of this message
andrey Fri Jul 23 15:51:27 1999 EDT Added files: /php4/ext/standard parsedate.y Modified files: /php4/ext/standard Makefile.am basic_functions.c datetime.c datetime.h Log: Ported strtotime() function. Index: php4/ext/standard/Makefile.am diff -u php4/ext/standard/Makefile.am:1.6 php4/ext/standard/Makefile.am:1.7 --- php4/ext/standard/Makefile.am:1.6 Sat Jun 12 13:50:38 1999 +++ php4/ext/standard/Makefile.am Fri Jul 23 15:51:26 1999 @@ -7,7 +7,8 @@ html.c image.c info.c link.c mail.c math.c md5.c microtime.c \ pack.c pageinfo.c rand.c reg.c soundex.c string.c \ syslog.c type.c uniqid.c url.c iptc.c var.c quot_print.c \ - cyr_convert.c flock_compat.c crypt.c dl.c head.c post.c + cyr_convert.c flock_compat.c crypt.c dl.c head.c post.c \ + parsedate.y #number.o: number.c # $(CC) $(CFLAGS) -w@WARNING_LEVEL@ -c $< -o $@ Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.49 php4/ext/standard/basic_functions.c:1.50 --- php4/ext/standard/basic_functions.c:1.49 Thu Jul 22 11:15:40 1999 +++ php4/ext/standard/basic_functions.c Fri Jul 23 15:51:26 1999 @@ -84,6 +84,7 @@ #if HAVE_STRFTIME {"strftime", php3_strftime, NULL}, #endif + PHP_FE(strtotime, NULL) {"date", php3_date, NULL}, {"gmdate", php3_gmdate, NULL}, {"getdate", php3_getdate, NULL}, Index: php4/ext/standard/datetime.c diff -u php4/ext/standard/datetime.c:1.13 php4/ext/standard/datetime.c:1.14 --- php4/ext/standard/datetime.c:1.13 Thu Jul 22 11:15:41 1999 +++ php4/ext/standard/datetime.c Fri Jul 23 15:51:27 1999 @@ -19,7 +19,7 @@ */ -/* $Id: datetime.c,v 1.13 1999/07/22 15:15:41 andrey Exp $ */ +/* $Id: datetime.c,v 1.14 1999/07/23 19:51:27 andrey Exp $ */ #include "php.h" @@ -62,6 +62,8 @@ #define isleap(year) (((year%4) == 0 && (year%100)!=0) || (year%400)==0) +extern PHPAPI time_t parsedate(char *p, struct timeval *now); + PHP_FUNCTION(time) { return_value->value.lval = (long) time(NULL); @@ -550,6 +552,32 @@ RETURN_FALSE; } #endif + +/* {{{ proto int strtotime(string time, int now) */ +PHP_FUNCTION(strtotime) +{ + 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: php4/ext/standard/datetime.h diff -u php4/ext/standard/datetime.h:1.2 php4/ext/standard/datetime.h:1.3 --- php4/ext/standard/datetime.h:1.2 Sun May 16 07:19:25 1999 +++ php4/ext/standard/datetime.h Fri Jul 23 15:51:27 1999 @@ -29,7 +29,7 @@ */ -/* $Id: datetime.h,v 1.2 1999/05/16 11:19:25 sas Exp $ */ +/* $Id: datetime.h,v 1.3 1999/07/23 19:51:27 andrey Exp $ */ #ifndef _DATETIME_H #define _DATETIME_H @@ -44,6 +44,7 @@ #if HAVE_STRFTIME PHP_FUNCTION(strftime); #endif +PHP_FUNCTION(strtotime); extern char *php3_std_date(time_t t); void _php3_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm);

« previous php.version4 (#2638) next »