Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 33... Línea 33...
33
     */
33
     */
34
    public function __construct(
34
    public function __construct(
35
        ?int $time = null,
35
        ?int $time = null,
36
    ) {
36
    ) {
37
        if ($time) {
37
        if ($time) {
-
 
38
            // Note that the constructor with time zone does not work when specifying a timestamp,
-
 
39
            // so we have to set timezone separately afterward.
38
            $this->time = new \DateTimeImmutable("@{$time}");
40
            $this->time = (new \DateTimeImmutable("@{$time}"))
-
 
41
                ->setTimezone(\core_date::get_server_timezone_object());
39
        } else {
42
        } else {
40
            $this->time = new \DateTimeImmutable();
43
            $this->time = (new \DateTimeImmutable())->setTimezone(\core_date::get_server_timezone_object());
41
        }
44
        }
42
    }
45
    }
Línea 43... Línea 46...
43
 
46
 
44
    public function now(): \DateTimeImmutable {
47
    public function now(): \DateTimeImmutable {
Línea 53... Línea 56...
53
     * Set the time of the clock.
56
     * Set the time of the clock.
54
     *
57
     *
55
     * @param int $time
58
     * @param int $time
56
     */
59
     */
57
    public function set_to(int $time): void {
60
    public function set_to(int $time): void {
58
        $this->time = new \DateTimeImmutable("@{$time}");
61
        $this->time = (new \DateTimeImmutable("@{$time}"))
-
 
62
            ->setTimezone(\core_date::get_server_timezone_object());
59
    }
63
    }
Línea 60... Línea 64...
60
 
64
 
61
    /**
65
    /**
62
     * Bump the time by a number of seconds.
66
     * Bump the time by a number of seconds.