Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 24... Línea 24...
24
 */
24
 */
25
class incrementing_clock implements \core\clock {
25
class incrementing_clock implements \core\clock {
26
    /** @var int The next time of the clock */
26
    /** @var int The next time of the clock */
27
    public int $time;
27
    public int $time;
Línea -... Línea 28...
-
 
28
 
-
 
29
    /** @var DateTimeZone The system timezone. */
-
 
30
    protected DateTimeZone $timezone;
28
 
31
 
29
    /**
32
    /**
30
     * Create a new instance of the incrementing clock.
33
     * Create a new instance of the incrementing clock.
31
     *
34
     *
32
     * @param null|int $starttime The initial time to use. If not specified, the current time is used.
35
     * @param null|int $starttime The initial time to use. If not specified, the current time is used.
33
     */
36
     */
34
    public function __construct(
37
    public function __construct(
35
        ?int $starttime = null,
38
        ?int $starttime = null,
36
    ) {
39
    ) {
-
 
40
        $this->time = $starttime ?? time();
37
        $this->time = $starttime ?? time();
41
        $this->timezone = \core_date::get_server_timezone_object();
Línea 38... Línea 42...
38
    }
42
    }
39
 
43
 
40
    public function now(): \DateTimeImmutable {
44
    public function now(): \DateTimeImmutable {
Línea 41... Línea 45...
41
        return new \DateTimeImmutable('@' . $this->time++);
45
        return (new \DateTimeImmutable('@' . $this->time++))->setTimezone($this->timezone);
42
    }
46
    }
43
 
47