diff options
author | Hartmut Holzgraefe <hholzgra@php.net> | 2000-04-16 11:40:19 +0000 |
---|---|---|
committer | Hartmut Holzgraefe <hholzgra@php.net> | 2000-04-16 11:40:19 +0000 |
commit | 0866fef791a4498205e6ed0b55f3919678c1b9cf (patch) | |
tree | 6e476e3c9dff7af2741bab64df09aadd5eac6151 | |
parent | 4e1f9412cf37cdd8cdeee5ce1a30f30ad83b4e1f (diff) | |
download | php-git-0866fef791a4498205e6ed0b55f3919678c1b9cf.tar.gz |
added unixtojd() and jdtounix() to convert from unix time_t to
Julian Days and vice versa
-rw-r--r-- | ext/calendar/Makefile.in | 2 | ||||
-rw-r--r-- | ext/calendar/calendar.c | 46 | ||||
-rw-r--r-- | ext/calendar/easter.c | 38 | ||||
-rw-r--r-- | ext/calendar/php_calendar.h | 2 |
4 files changed, 51 insertions, 37 deletions
diff --git a/ext/calendar/Makefile.in b/ext/calendar/Makefile.in index 1a66a8d8c5..9ffcafdc38 100644 --- a/ext/calendar/Makefile.in +++ b/ext/calendar/Makefile.in @@ -6,6 +6,6 @@ srcdir = @srcdir@ VPATH = @srcdir@ LTLIBRARY_NAME = libcalendar.la -LTLIBRARY_SOURCES = calendar.c dow.c french.c gregor.c jewish.c julian.c easter.c +LTLIBRARY_SOURCES = calendar.c dow.c french.c gregor.c jewish.c julian.c easter.c cal_unix.c include $(topsrcdir)/build/ltlib.mk diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c index fd70a6497d..3baccadd48 100644 --- a/ext/calendar/calendar.c +++ b/ext/calendar/calendar.c @@ -1,9 +1,23 @@ -/* interface functions. - - * code by Shane Caraveo shane@caraveo.com - * copy freely! - * +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Shane Caraveo <shane@caraveo.com> | + | Colin Viebrock <cmv@easydns.com> | + | Hartmut Holzgraefe <hartmut@six.de> | + +----------------------------------------------------------------------+ */ +/* $Id: */ #include "php.h" #include "php_calendar.h" @@ -22,6 +36,8 @@ function_entry calendar_functions[] = { PHP_FE(jdmonthname, NULL) PHP_FE(easter_date, NULL) PHP_FE(easter_days, NULL) + PHP_FE(unixtojd, NULL) + PHP_FE(jdtounix, NULL) {NULL, NULL, NULL} }; @@ -222,26 +238,30 @@ PHP_FUNCTION(jdtogregorian) } /* }}} */ -/* {{{ proto mixed jddayofweek(int juliandaycount, int mode) +/* {{{ proto mixed jddayofweek(int juliandaycount, [int mode]) Returns name or number of day of week from julian day count */ PHP_FUNCTION(jddayofweek) { - pval **julday, **mode; + pval *julday, *mode; int day; char *daynamel, *daynames; - - if (zend_get_parameters_ex(2, &julday, &mode) != SUCCESS) { + int myargc=ARG_COUNT(ht),mymode=0; + + if ((myargc < 1) || (myargc > 2) || (zend_get_parameters(ht,myargc, &julday, &mode) != SUCCESS)) { WRONG_PARAM_COUNT; } - convert_to_long_ex(julday); - convert_to_long_ex(mode); + convert_to_long(julday); + if(myargc==2) { + convert_to_long(mode); + mymode = mode->value.lval; + } - day = DayOfWeek((*julday)->value.lval); + day = DayOfWeek(julday->value.lval); daynamel = DayNameLong[day]; daynames = DayNameShort[day]; - switch ((*mode)->value.lval) { + switch (mymode) { case 0L: RETURN_LONG(day); break; diff --git a/ext/calendar/easter.c b/ext/calendar/easter.c index 56a4b32ca4..b7ddf29537 100644 --- a/ext/calendar/easter.c +++ b/ext/calendar/easter.c @@ -1,31 +1,23 @@ /* +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | + | PHP version 4.0 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-9 PHP Development Team (See Credits file) | + | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | + | This source file is subject to version 2.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Colin Viebrock <cmv@easydns.com> | + | Authors: Shane Caraveo <shane@caraveo.com> | + | Colin Viebrock <cmv@easydns.com> | + | Hartmut Holzgraefe <hartmut@six.de> | +----------------------------------------------------------------------+ */ +/* $Id: */ #include "php.h" #include "php_calendar.h" @@ -40,7 +32,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, int gm) pval *year_arg; struct tm *ta, te; time_t the_time; - int year, golden, solar, lunar, pfm, dom, tmp, easter; + long year, golden, solar, lunar, pfm, dom, tmp, easter; switch(ARG_COUNT(ht)) { case 0: @@ -58,7 +50,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, int gm) default: WRONG_PARAM_COUNT; } - + if (gm && (year<1970 || year>2037)) { /* out of range for timestamps */ php3_error(E_WARNING, "easter_date() is only valid for years between 1970 and 2037 inclusive"); RETURN_FALSE; diff --git a/ext/calendar/php_calendar.h b/ext/calendar/php_calendar.h index b630d9c4e1..aef771558e 100644 --- a/ext/calendar/php_calendar.h +++ b/ext/calendar/php_calendar.h @@ -27,6 +27,8 @@ PHP_FUNCTION(jddayofweek); PHP_FUNCTION(jdmonthname); PHP_FUNCTION(easter_days); PHP_FUNCTION(easter_date); +PHP_FUNCTION(unixtojd); +PHP_FUNCTION(jdtounix); #define phpext_calendar_ptr calendar_module_ptr |