fix format week of year

This commit is contained in:
nasser committed 2022-02-04 23:32:43 +03:30
1 parent a820b93899
commit 5bf4395e9b
1 file changed
+17 -2
+17 -2
View File
@@ -117,7 +117,7 @@ trait Formatting
# Week # Week
case 'W': case 'W':
return ceil( $this->daysYear( $pMonth, $pDay ) / 7 ); return $this->dayOfWeek();
# Month # Month
case 'F': case 'F':
@@ -245,6 +245,21 @@ trait Formatting
return ($days + $day); return ($days + $day);
} }
/**
* return week number from first of year
*
* @param int $month
* @param int $day
* @return type
* @since 5.0.0
*/
protected function dayOfWeek()
{
$offset = $this->clone()->startYear()->format('w');
$days = $this->format('z');
return ceil( ($days + $offset) / 7 );
}
/** /**
* The format of the outputted date string (jalali equivalent of php strftime() function) * The format of the outputted date string (jalali equivalent of php strftime() function)
* *
@@ -452,4 +467,4 @@ trait Formatting
return str_replace(array_values($ar['numbers']), array_values($en['numbers']), $string); return str_replace(array_values($ar['numbers']), array_values($en['numbers']), $string);
} }
} }