Skip to content

Commit

Permalink
Merge branch 'MDL-80692-402' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_402_STABLE
  • Loading branch information
HuongNV13 committed Feb 1, 2024
2 parents 2beaddf + dd46cc6 commit 41b9d54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
21 changes: 9 additions & 12 deletions calendar/classes/external/calendar_day_exporter.php
Expand Up @@ -14,22 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Contains event class for displaying the day view.
*
* @package core_calendar
* @copyright 2017 Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace core_calendar\external;

defined('MOODLE_INTERNAL') || die();

use core\external\exporter;
use core_date;
use DateTimeImmutable;
use renderer_base;
use moodle_url;
use \core_calendar\local\event\container;
use core_calendar\local\event\container;

/**
* Class for displaying the day view.
Expand Down Expand Up @@ -209,7 +201,12 @@ protected function get_other_values(renderer_base $output) {

// Need to account for user's timezone.
$usernow = usergetdate(time());
$today = new \DateTimeImmutable();
$today = new DateTimeImmutable(
timezone: core_date::get_user_timezone_object(),
);

// The start time should use the day's date but the current
// time of the day (adjusted for user's timezone).
$neweventtimestamp = $today->setTimestamp($date[0])->setTime(
$usernow['hours'],
$usernow['minutes'],
Expand Down
15 changes: 6 additions & 9 deletions calendar/classes/external/day_exporter.php
Expand Up @@ -14,21 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Contains event class for displaying the day view.
*
* @package core_calendar
* @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace core_calendar\external;

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/calendar/lib.php');

use core\external\exporter;
use core_date;
use DateTimeImmutable;
use renderer_base;
use moodle_url;

Expand Down Expand Up @@ -169,7 +163,10 @@ protected function get_other_values(renderer_base $output) {
$timestamp = $this->data[0];
// Need to account for user's timezone.
$usernow = usergetdate(time());
$today = new \DateTimeImmutable();
$today = new DateTimeImmutable(
timezone: core_date::get_user_timezone_object(),
);

// The start time should use the day's date but the current
// time of the day (adjusted for user's timezone).
$neweventstarttime = $today->setTimestamp($timestamp)->setTime(
Expand Down

0 comments on commit 41b9d54

Please sign in to comment.