fix test last month
This commit is contained in:
1 parent
40e00c1fa2
commit
84a873f345
6 files changed
+19
-30
No files matched your search
@@ -395,7 +395,7 @@ trait Comparison
|
||||
*/
|
||||
public function isNextMonth()
|
||||
{
|
||||
return $this->month === static::now($this->getTimezone())->addMonth()->month;
|
||||
return $this->format('Y-m') === static::now($this->getTimezone())->addMonth()->format('Y-m');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,7 +405,7 @@ trait Comparison
|
||||
*/
|
||||
public function isLastMonth()
|
||||
{
|
||||
return $this->month === static::now($this->getTimezone())->subMonth()->month;
|
||||
return $this->format('Y-m') === static::now($this->getTimezone())->subMonth()->format('Y-m');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -458,7 +458,7 @@ trait Comparison
|
||||
*/
|
||||
public function isSameAs($format, Verta $v = null)
|
||||
{
|
||||
$v = $v ?: static::now($this->timezone);
|
||||
$v = $v ?: static::now($this->getTimezone());
|
||||
|
||||
return $this->format($format) === $v->format($format);
|
||||
}
|
||||
|
||||
@@ -12,16 +12,14 @@ trait Creator
|
||||
/**
|
||||
* create object of Jalali
|
||||
*
|
||||
* @param null $datetime
|
||||
* @param bool $timezone [optional]
|
||||
* @param DateTime|string|int|null $datetime [optional]
|
||||
* @param DateTimeZone|string|null $timezone [optional]
|
||||
* @internal param timestamp $timestamp [optional]
|
||||
*/
|
||||
public function __construct($datetime = null, $timezone = null)
|
||||
{
|
||||
$dt = $datetime;
|
||||
if (static::$testNow) {
|
||||
$dt = static::$testNow;
|
||||
} elseif (empty($datetime)) {
|
||||
if (empty($datetime)) {
|
||||
$dt = 'now';
|
||||
} elseif (is_string($datetime)) {
|
||||
$dt = self::faToEnNumbers(self::arToEnNumbers($datetime));
|
||||
@@ -254,7 +252,7 @@ trait Creator
|
||||
|
||||
/**
|
||||
* @param null $timezone
|
||||
* @return DateTimeZone|null
|
||||
* @return DateTimeZone|string|null
|
||||
*/
|
||||
protected static function createTimeZone($timezone = null)
|
||||
{
|
||||
|
||||
+9
-17
@@ -6,23 +6,15 @@ use Hekmatinasser\Verta\VertaInterface;
|
||||
|
||||
trait Date
|
||||
{
|
||||
use Accessor;
|
||||
use Comparison;
|
||||
use Creator;
|
||||
use Formatting;
|
||||
use Modification;
|
||||
use Transformation;
|
||||
use Translator;
|
||||
use Boundaries;
|
||||
use Difference;
|
||||
|
||||
/**
|
||||
* Format to use for __toString.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $testNow = null;
|
||||
|
||||
use Accessor,
|
||||
Comparison,
|
||||
Creator,
|
||||
Formatting,
|
||||
Modification,
|
||||
Transformation,
|
||||
Translator,
|
||||
Boundaries,
|
||||
Difference;
|
||||
/**
|
||||
* Format to use for __toString.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user