fix format

This commit is contained in:
Nasser committed 2020-11-13 22:32:37 +03:30
1 parent 48f0d688fe
commit fe687e25e3
2 files changed
+10 -14

No files matched your search

+3 -4
View File
@@ -4,7 +4,6 @@
namespace Hekmatinasser\Verta\Traits;
use DateTime;
use DateTimeInterface;
use DateTimeZone;
use Exception;
use InvalidArgumentException;
@@ -62,7 +61,7 @@ trait Creator
public static function today($timezone = null)
{
return static::now($timezone)->startDay();
return (new static($timezone))->startDay();
}
/**
@@ -74,7 +73,7 @@ trait Creator
*/
public static function tomorrow($timezone = null)
{
return static::today($timezone)->addDay();
return (new static('+1 day', $timezone))->startDay();
}
/**
@@ -86,7 +85,7 @@ trait Creator
*/
public static function yesterday($timezone = null)
{
return static::today($timezone)->subDay();
return (new static('-1 day', $timezone))->startDay();
}
/**
+7 -10
View File
@@ -48,7 +48,7 @@ trait Formatting
$timestamp = $this->getTimestamp();
list( $gYear, $gMonth, $gDay, $gWeek ) = explode( '-', date('Y-m-d-w', $timestamp) );
list( $gYear, $gMonth, $gDay, $gWeek ) = explode( '-', parent::format('Y-m-d-w'));
list( $pYear, $pMonth, $pDay ) = static::getJalali( $gYear, $gMonth, $gDay );
$pWeek = ( $gWeek + 1 );
@@ -205,7 +205,7 @@ trait Formatting
$timestamp = $this->getTimestamp();
list($gYear, $gMonth, $gDay, $gWeek) = explode('-', date('Y-m-d-w', $timestamp));
list($gYear, $gMonth, $gDay, $gWeek) = explode('-', parent::format('Y-m-d-w'));
list($pYear, $pMonth, $pDay) = static::getJalali($gYear, $gMonth, $gDay);
$pWeek = ($gWeek + 1);
@@ -300,14 +300,10 @@ trait Formatting
# Time
case 'a':
$result .= (parent::format('a') == 'am' ? self::AM : self::PM);
case 'A':
if (date('a', $timestamp) == 'am') {
$result .= (($par == 'a') ? self::AM : self::ANTE_MERIDIEM);
} else {
$result .= (($par == 'a') ? self::PM : self::POST_MERIDIEM);
}
$result .= (parent::format('a') == 'am' ? self::ANTE_MERIDIEM : self::POST_MERIDIEM);
break;
case 'B':
case 'g':
case 'G':
@@ -316,7 +312,7 @@ trait Formatting
case 's':
case 'u':
case 'i':
$result .= $word->getWord(strval(date($par, $timestamp)));
$result .= $word->getWord(strval(parent::format($par)));
break;
case 'e':
case 'I':
@@ -324,7 +320,7 @@ trait Formatting
case 'P':
case 'T':
case 'Z':
$result .= date($par, $timestamp);
$result .= parent::format($par);
break;
# Full Date/Time
@@ -481,6 +477,7 @@ trait Formatting
public function formatGregorian($format) {
return $this->datetime()->format($format);
return $this->datetime()->format($format);
}
/**