123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #include "php.h"
- #include "php_calendar.h"
- #include "sdncal.h"
- #include <time.h>
- PHP_FUNCTION(unixtojd)
- {
- time_t ts = 0;
- struct tm *ta, tmbuf;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &ts) == FAILURE) {
- return;
- }
- if (!ts) {
- ts = time(NULL);
- } else if (ts < 0) {
- RETURN_FALSE;
- }
- if (!(ta = php_localtime_r(&ts, &tmbuf))) {
- RETURN_FALSE;
- }
- RETURN_LONG(GregorianToSdn(ta->tm_year+1900, ta->tm_mon+1, ta->tm_mday));
- }
- PHP_FUNCTION(jdtounix)
- {
- long uday;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &uday) == FAILURE) {
- return;
- }
- uday -= 2440588 ;
- if (uday < 0 || uday > 24755) {
- RETURN_FALSE;
- }
- RETURN_LONG(uday * 24 * 3600);
- }
|