Skip to content

Commit

Permalink
Implement timecop_unixtojd
Browse files Browse the repository at this point in the history
  • Loading branch information
hnw committed Aug 12, 2012
1 parent 3824157 commit 2acd8c2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions php_timecop.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ PHP_FUNCTION(timecop_localtime);
PHP_FUNCTION(timecop_strtotime);
PHP_FUNCTION(timecop_strftime);
PHP_FUNCTION(timecop_gmstrftime);
PHP_FUNCTION(timecop_unixtojd);

PHP_METHOD(TimecopDateTime, __construct);

Expand Down
19 changes: 19 additions & 0 deletions tests/overload11.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Function overloading test for unixtojd
--SKIPIF--
<?php
extension_loaded('timecop') or die('skip timecop not available');
$required_func = array("timecop_strtotime", "timecop_freeze", "unixtojd", "timecop_orig_unixtojd");
foreach ($required_func as $func_name) {
if (!function_exists($func_name)) {
die("skip $func_name() function is not available.");
}
}
--INI--
timecop.func_overload=1
--FILE--
<?php
timecop_freeze(timecop_strtotime("2012-02-29 01:23:45"));
var_dump(unixtojd());
--EXPECT--
int(2455987)
10 changes: 10 additions & 0 deletions timecop.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static const struct timecop_overload_def timecop_ovld_func[] = {
{"strtotime", "timecop_strtotime", "timecop_orig_strtotime"},
{"strftime", "timecop_strftime", "timecop_orig_strftime"},
{"gmstrftime", "timecop_gmstrftime", "timecop_orig_gmstrftime"},
{"unixtojd", "timecop_unixtojd", "timecop_orig_unixtojd"},
{NULL, NULL, NULL}
};
/* }}} */
Expand All @@ -75,6 +76,7 @@ const zend_function_entry timecop_functions[] = {
PHP_FE(timecop_strtotime, NULL)
PHP_FE(timecop_strftime, NULL)
PHP_FE(timecop_gmstrftime, NULL)
PHP_FE(timecop_unixtojd, NULL)
PHP_FE_END
};
/* }}} */
Expand Down Expand Up @@ -535,6 +537,14 @@ PHP_FUNCTION(timecop_gmstrftime)
}
/* }}} */

/* {{{ proto int timecop_unixtojd([int timestamp])
Convert UNIX timestamp to Julian Day */
PHP_FUNCTION(timecop_unixtojd)
{
_timecop_call_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "unixtojd", "timecop_orig_unixtojd", 0);
}
/* }}} */

/* {{{ proto TimecopDateTime::__construct([string time[, DateTimeZone object]])
Creates new TimecopDateTime object
*/
Expand Down

0 comments on commit 2acd8c2

Please sign in to comment.