xref: /webtrees/app/Contracts/TimestampFactoryInterface.php (revision 1ff45046fabc22237b5d0d8e489c96f031fc598d)
1d97083feSGreg Roach<?php
2d97083feSGreg Roach
3d97083feSGreg Roach/**
4d97083feSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6d97083feSGreg Roach * This program is free software: you can redistribute it and/or modify
7d97083feSGreg Roach * it under the terms of the GNU General Public License as published by
8d97083feSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9d97083feSGreg Roach * (at your option) any later version.
10d97083feSGreg Roach * This program is distributed in the hope that it will be useful,
11d97083feSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12d97083feSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13d97083feSGreg Roach * GNU General Public License for more details.
14d97083feSGreg Roach * You should have received a copy of the GNU General Public License
15d97083feSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16d97083feSGreg Roach */
17d97083feSGreg Roach
18d97083feSGreg Roachdeclare(strict_types=1);
19d97083feSGreg Roach
20d97083feSGreg Roachnamespace Fisharebest\Webtrees\Contracts;
21d97083feSGreg Roach
22d97083feSGreg Roach/**
23d97083feSGreg Roach * Create a timestamp object.
24d97083feSGreg Roach */
25d97083feSGreg Roachinterface TimestampFactoryInterface
26d97083feSGreg Roach{
27d97083feSGreg Roach    /**
28d97083feSGreg Roach     * @param int                $timestamp
29d97083feSGreg Roach     * @param UserInterface|null $user
30d97083feSGreg Roach     *
31d97083feSGreg Roach     * @return TimestampInterface
32d97083feSGreg Roach     */
332c6f1bd5SGreg Roach    public function make(int $timestamp, UserInterface|null $user = null): TimestampInterface;
34d97083feSGreg Roach
35d97083feSGreg Roach    /**
36d97083feSGreg Roach     * @param string|null        $string YYYY-MM-DD HH:MM:SS (as provided by SQL).
37d97083feSGreg Roach     * @param string             $format
38d97083feSGreg Roach     * @param UserInterface|null $user
39d97083feSGreg Roach     *
40d97083feSGreg Roach     * @return TimestampInterface
41d97083feSGreg Roach     */
42*1ff45046SGreg Roach    public function fromString(string|null $string, string $format = 'Y-m-d H:i:s', UserInterface|null $user = null): TimestampInterface;
43d97083feSGreg Roach
44d97083feSGreg Roach    /**
45d97083feSGreg Roach     * @param UserInterface|null $user
46d97083feSGreg Roach     *
47d97083feSGreg Roach     * @return TimestampInterface
48d97083feSGreg Roach     */
492c6f1bd5SGreg Roach    public function now(UserInterface|null $user = null): TimestampInterface;
50d97083feSGreg Roach}
51