Skip to content

Commit

Permalink
Implement timecop_date_create() / Do refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hnw committed Mar 5, 2013
1 parent a5f2fc4 commit 254c5bf
Show file tree
Hide file tree
Showing 3 changed files with 276 additions and 363 deletions.
1 change: 1 addition & 0 deletions php_timecop.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ PHP_FUNCTION(timecop_strtotime);
PHP_FUNCTION(timecop_strftime);
PHP_FUNCTION(timecop_gmstrftime);
PHP_FUNCTION(timecop_unixtojd);
PHP_FUNCTION(timecop_date_create);

PHP_METHOD(TimecopDateTime, __construct);

Expand Down
33 changes: 33 additions & 0 deletions tests/overload14.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--TEST--
Function overrideing test for date_create
--SKIPIF--
<?php
extension_loaded('timecop') or die('skip timecop not available');
$required_func = array("timecop_freeze", "timecop_orig_strtotime", "date_create");
foreach ($required_func as $func_name) {
if (!function_exists($func_name)) {
die("skip $func_name() function is not available.");
}
}
$required_class = array("datetime");
foreach ($required_class as $class_name) {
if (!class_exists($class_name)) {
die("skip $class_name class is not available.");
}
}
--INI--
date.timezone=America/Los_Angeles
--FILE--
<?php
timecop_freeze(timecop_orig_strtotime("2012-02-29 01:23:45"));

// constuctor with 0 argument
$dt = date_create();
var_dump($dt->format("c"));

// constuctor with 1 argument
$dt2 = date_create("+3days");
var_dump($dt2->format("c"));
--EXPECT--
string(25) "2012-02-29T01:23:45-08:00"
string(25) "2012-03-03T01:23:45-08:00"
Loading

0 comments on commit 254c5bf

Please sign in to comment.