diff --git a/docs/en/index.html b/docs/en/index.html index d1cef0f..4c922bb 100644 --- a/docs/en/index.html +++ b/docs/en/index.html @@ -221,6 +221,7 @@ $v = $v->setTimeString('12:25:48'); $v = verta(); return $v->format('Y-n-j H:i'); // 1395-10-7 14:12 return $v->format('%B %d، %Y'); // دی 07، 1395 +return $v->format('%Q %Y'); // زمستان 1395 return $v; //1395-10-07 14:12:32

Read the PHP manual to create the format you want

@@ -390,7 +391,6 @@ return $v1->isNextYear(); // false return $v1->isLastYear(); // false return $v1->isFuture(); // false return $v1->isPast(); // false -return $v1->isPast(); // false return $v1->isCurrentYear(); // true return $v1->isSameAs('y', $v2); // true isSameYear() diff --git a/docs/index.html b/docs/index.html index 582e072..0df290e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -226,6 +226,7 @@ $v = $v->setTimeString('12:25:48'); $v = verta(); return $v->format('Y-n-j H:i'); // 1395-10-7 14:12 return $v->format('%B %d، %Y'); // دی 07، 1395 +return $v->format('%Q %Y'); // زمستان 1395 return $v; //1395-10-07 14:12:32

برای ساخت فرمت نمایش مورد نظر خود راهنمای پی اچ پی را مطالعه کنید

@@ -395,7 +396,6 @@ return $v1->isNextYear(); // false return $v1->isLastYear(); // false return $v1->isFuture(); // false return $v1->isPast(); // false -return $v1->isPast(); // false return $v1->isCurrentYear(); // true return $v1->isSameAs('y', $v2); // true isSameYear() diff --git a/src/Lang/ar.php b/src/Lang/ar.php index 0e96ab2..cb53bed 100644 --- a/src/Lang/ar.php +++ b/src/Lang/ar.php @@ -72,6 +72,12 @@ return [ 'jdate_before_equal' => 'يجب أن يكون :attribute تاريخ جلالي قبل :date أو يساوي.', 'jdatetime_before' => 'يجب أن يكون :attribute هو تاريخ جلالي قبل :date.', 'jdatetime_before_equal' => 'يجب أن يكون :attribute هو تاريخ جلالي قبل أو يساوي :date.', + ], + 'quarters' => [ + '1' => 'ربيع', + '2' => 'الصيف', + '3' => 'الخريف', + '4' => 'شتاء', ] ]; diff --git a/src/Lang/az.php b/src/Lang/az.php index cfe6519..83b069e 100644 --- a/src/Lang/az.php +++ b/src/Lang/az.php @@ -72,6 +72,12 @@ return [ 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', + ], + 'quarters' => [ + '1' => 'بهار', + '2' => 'تابستان', + '3' => 'پاییز', + '4' => 'زمستان', ] ]; diff --git a/src/Lang/en.php b/src/Lang/en.php index 1220dbe..8d0e9b4 100644 --- a/src/Lang/en.php +++ b/src/Lang/en.php @@ -72,6 +72,12 @@ return [ 'jdate_before_equal' => 'The :attribute must be a Jalali date before or equal :date.', 'jdatetime_before' => 'The :attribute must be a Jalali datetime before :date.', 'jdatetime_before_equal' => 'The :attribute must be a Jalali datetime before or equal :date.', + ], + 'quarters' => [ + '1' => 'spring', + '2' => 'summer', + '3' => 'autumn', + '4' => 'winter', ] ]; diff --git a/src/Lang/fa.php b/src/Lang/fa.php index 9ad6e9d..15dcaad 100644 --- a/src/Lang/fa.php +++ b/src/Lang/fa.php @@ -72,6 +72,12 @@ return [ 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', + ], + 'quarters' => [ + '1' => 'بهار', + '2' => 'تابستان', + '3' => 'پاییز', + '4' => 'زمستان', ] ]; diff --git a/src/Lang/haz.php b/src/Lang/haz.php index cc8d370..8d76699 100644 --- a/src/Lang/haz.php +++ b/src/Lang/haz.php @@ -72,6 +72,12 @@ return [ 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', + ], + 'quarters' => [ + '1' => 'بهار', + '2' => 'تابستان', + '3' => 'پاییز', + '4' => 'زمستان', ] ]; diff --git a/src/Lang/ku.php b/src/Lang/ku.php index 87315a6..452c963 100644 --- a/src/Lang/ku.php +++ b/src/Lang/ku.php @@ -72,6 +72,12 @@ return [ 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', + ], + 'quarters' => [ + '1' => 'بهار', + '2' => 'تابستان', + '3' => 'پاییز', + '4' => 'زمستان', ] ]; diff --git a/src/Lang/ps.php b/src/Lang/ps.php index 7e759f3..f5170a9 100644 --- a/src/Lang/ps.php +++ b/src/Lang/ps.php @@ -71,6 +71,12 @@ return [ 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', + ], + 'quarters' => [ + '1' => 'بهار', + '2' => 'تابستان', + '3' => 'پاییز', + '4' => 'زمستان', ] ]; diff --git a/src/Traits/Formatting.php b/src/Traits/Formatting.php index 9fb6548..96840de 100644 --- a/src/Traits/Formatting.php +++ b/src/Traits/Formatting.php @@ -134,7 +134,10 @@ trait Formatting case 't': return static::isLeapYear( $pYear ) && ( $pMonth == 12 ) ? 30 : static::$daysMonthJalali[ intval( $pMonth ) - 1 ]; - + # Quarter + case 'Q': + case 'q': + return self::$messages['quarters'][$this->quarter]; # Years case 'L': return intval( $this->isLeapYear( $pYear ) ); @@ -291,6 +294,8 @@ trait Formatting "%n" => "\n", "%t" => "\t", "%%" => "%", + "%Q" => "q", + "%q" => "q" ); return str_replace(array_keys($strftime_date), array_values($strftime_date), $format); diff --git a/tests/FormatTest.php b/tests/FormatTest.php index 2d8e9e2..81ed3fd 100644 --- a/tests/FormatTest.php +++ b/tests/FormatTest.php @@ -120,4 +120,11 @@ class FormatTest extends TestCase $this->assertEquals('چهارشنبه یازده ام دی', $datetime); } + + public function testFormatQuarter() + { + $datetime = Verta::parse('1398-10-10 21:30:50')->formatWord('q'); + + $this->assertEquals('زمستان', $datetime); + } }