mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-59750 core_calendar: add next and previous days handling methods
This commit is contained in:
parent
8afe9f8a14
commit
578eb78981
@ -239,4 +239,32 @@ abstract class type_base {
|
||||
$gregorianinfo['minute'],
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the previous day.
|
||||
*
|
||||
* @param int $daytimestamp The day timestamp.
|
||||
* @return int previous day timestamp
|
||||
*/
|
||||
public function get_prev_day($daytimestamp) {
|
||||
$date = new \DateTime();
|
||||
$date->setTimestamp($daytimestamp);
|
||||
$date->modify('-1 day');
|
||||
|
||||
return $date->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next day.
|
||||
*
|
||||
* @param int $daytimestamp The day timestamp.
|
||||
* @return int the following day
|
||||
*/
|
||||
public function get_next_day($daytimestamp) {
|
||||
$date = new \DateTime();
|
||||
$date->setTimestamp($daytimestamp);
|
||||
$date->modify('+1 day');
|
||||
|
||||
return $date->getTimestamp();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user