Add Carbon::quarter_string
This commit is contained in:
parent
4b25f97314
commit
a4650f8710
@ -15,10 +15,13 @@ class Carbon extends CarbonBase
|
|||||||
|
|
||||||
public function __get($name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
switch (true) {
|
switch ($name) {
|
||||||
case $name === 'half':
|
case 'half':
|
||||||
return (int) ceil($this->month / static::MONTHS_PER_HALF);
|
return (int) ceil($this->month / static::MONTHS_PER_HALF);
|
||||||
|
|
||||||
|
case 'quarter_string':
|
||||||
|
return sprintf('%dQ%d',$this->year,$this->quarter);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return parent::__get($name);
|
return parent::__get($name);
|
||||||
}
|
}
|
||||||
@ -35,7 +38,7 @@ class Carbon extends CarbonBase
|
|||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
public function startOfHalf($dayOfWeek = null)
|
public function startOfHalf($dayOfWeek = null)
|
||||||
{
|
{
|
||||||
return $this->setDate($this->year, $this->half * static::MONTHS_PER_HALF - 5, 1)->firstOfMonth($dayOfWeek);
|
return $this->setDate($this->year, $this->half * static::MONTHS_PER_HALF - 5, 1)->firstOfMonth($dayOfWeek);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +53,7 @@ class Carbon extends CarbonBase
|
|||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
public function endOfHalf($dayOfWeek = null)
|
public function endOfHalf($dayOfWeek = null)
|
||||||
{
|
{
|
||||||
return $this->setDate($this->year, $this->half * static::MONTHS_PER_HALF, 1)->lastOfMonth($dayOfWeek);
|
return $this->setDate($this->year, $this->half * static::MONTHS_PER_HALF, 1)->lastOfMonth($dayOfWeek);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user