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; namespace Hekmatinasser\Verta\Traits;
use DateTime; use DateTime;
use DateTimeInterface;
use DateTimeZone; use DateTimeZone;
use Exception; use Exception;
use InvalidArgumentException; use InvalidArgumentException;
@@ -62,7 +61,7 @@ trait Creator
public static function today($timezone = null) 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) 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) 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(); $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 ); list( $pYear, $pMonth, $pDay ) = static::getJalali( $gYear, $gMonth, $gDay );
$pWeek = ( $gWeek + 1 ); $pWeek = ( $gWeek + 1 );
@@ -205,7 +205,7 @@ trait Formatting
$timestamp = $this->getTimestamp(); $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); list($pYear, $pMonth, $pDay) = static::getJalali($gYear, $gMonth, $gDay);
$pWeek = ($gWeek + 1); $pWeek = ($gWeek + 1);
@@ -300,14 +300,10 @@ trait Formatting
# Time # Time
case 'a': case 'a':
$result .= (parent::format('a') == 'am' ? self::AM : self::PM);
case 'A': case 'A':
if (date('a', $timestamp) == 'am') { $result .= (parent::format('a') == 'am' ? self::ANTE_MERIDIEM : self::POST_MERIDIEM);
$result .= (($par == 'a') ? self::AM : self::ANTE_MERIDIEM);
} else {
$result .= (($par == 'a') ? self::PM : self::POST_MERIDIEM);
}
break; break;
case 'B': case 'B':
case 'g': case 'g':
case 'G': case 'G':
@@ -316,7 +312,7 @@ trait Formatting
case 's': case 's':
case 'u': case 'u':
case 'i': case 'i':
$result .= $word->getWord(strval(date($par, $timestamp))); $result .= $word->getWord(strval(parent::format($par)));
break; break;
case 'e': case 'e':
case 'I': case 'I':
@@ -324,7 +320,7 @@ trait Formatting
case 'P': case 'P':
case 'T': case 'T':
case 'Z': case 'Z':
$result .= date($par, $timestamp); $result .= parent::format($par);
break; break;
# Full Date/Time # Full Date/Time
@@ -481,6 +477,7 @@ trait Formatting
public function formatGregorian($format) { public function formatGregorian($format) {
return $this->datetime()->format($format); return $this->datetime()->format($format);
return $this->datetime()->format($format);
} }
/** /**