Back to index

php5  5.3.10
Functions
cal_unix.c File Reference
#include "php.h"
#include "php_calendar.h"
#include "sdncal.h"
#include <time.h>

Go to the source code of this file.

Functions

 PHP_FUNCTION (unixtojd)
 PHP_FUNCTION (jdtounix)

Function Documentation

PHP_FUNCTION ( unixtojd  )

Definition at line 29 of file cal_unix.c.

{
       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));
}

Here is the call graph for this function:

PHP_FUNCTION ( jdtounix  )

Definition at line 54 of file cal_unix.c.

{
       long uday;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &uday) == FAILURE) {
              return;
       }      
       uday -= 2440588 /* J.D. of 1.1.1970 */;

       if (uday < 0 || uday > 24755) { /* before beginning of unix epoch or behind end of unix epoch */ 
              RETURN_FALSE;
       }

       RETURN_LONG(uday * 24 * 3600);
}

Here is the call graph for this function: