fix yesterday test now

This commit is contained in:
nasser committed 2022-02-16 13:38:40 +03:30
1 parent 3de8155088
commit 40e00c1fa2
2 files changed
+6 -5

No files matched your search

+5 -4
View File
@@ -18,6 +18,7 @@ trait Creator
*/ */
public function __construct($datetime = null, $timezone = null) public function __construct($datetime = null, $timezone = null)
{ {
$dt = $datetime;
if (static::$testNow) { if (static::$testNow) {
$dt = static::$testNow; $dt = static::$testNow;
} elseif (empty($datetime)) { } elseif (empty($datetime)) {
@@ -59,7 +60,7 @@ trait Creator
*/ */
public static function today($timezone = null) public static function today($timezone = null)
{ {
return (new static($timezone))->startDay(); return (new static(null, $timezone))->startDay();
} }
/** /**
@@ -71,7 +72,7 @@ trait Creator
*/ */
public static function tomorrow($timezone = null) public static function tomorrow($timezone = null)
{ {
return (new static('+1 day', $timezone))->startDay(); return (new static(null, $timezone))->addDay()->startDay();
} }
/** /**
@@ -83,14 +84,14 @@ trait Creator
*/ */
public static function yesterday($timezone = null) public static function yesterday($timezone = null)
{ {
return (new static('-1 day', $timezone))->startDay(); return (new static(null, $timezone))->subDay()->startDay();
} }
/** /**
* Create a Verta instance from a DateTime one * Create a Verta instance from a DateTime one
* *
* @param $datetime [optional] * @param $datetime [optional]
* @param bool $timezone [optional] * @param \DateTimeZone|string|null $timezone [optional]
* *
* @return static * @return static
*/ */
+1 -1
View File
@@ -244,7 +244,7 @@ class ComparisionTest extends TestCase
$this->assertEquals($result, Verta::parse('1398-10-10 21:30:55')); $this->assertEquals($result, Verta::parse('1398-10-10 21:30:55'));
} }
public function testIsDay() public function testIs()
{ {
$datetime = Verta::parse('1397-10-10 21:30:50'); $datetime = Verta::parse('1397-10-10 21:30:50');
$target = Verta::parse('1398-10-10 21:30:01'); $target = Verta::parse('1398-10-10 21:30:01');