xref: /webtrees/app/Contracts/TimestampInterface.php (revision 8e989043a1accd625c6a2ad78736ba5c3e0c20a1)
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 * A localized date-time.
24d97083feSGreg Roach */
25d97083feSGreg Roachinterface TimestampInterface
26d97083feSGreg Roach{
27d97083feSGreg Roach    /**
28d97083feSGreg Roach     * Convert a datetime to the user's Julian day number.
29d97083feSGreg Roach     *
30d97083feSGreg Roach     * @return int
31d97083feSGreg Roach     */
32d97083feSGreg Roach    public function julianDay(): int;
33d97083feSGreg Roach
34d97083feSGreg Roach    /**
35d97083feSGreg Roach     * @return string
36d97083feSGreg Roach     */
37d97083feSGreg Roach    public function diffForHumans(): string;
38d97083feSGreg Roach
39d97083feSGreg Roach    /**
40d97083feSGreg Roach     * @param string $format
41d97083feSGreg Roach     *
42d97083feSGreg Roach     * @return string
43d97083feSGreg Roach     */
44d97083feSGreg Roach    public function format(string $format): string;
45d97083feSGreg Roach
46d97083feSGreg Roach    /**
47d97083feSGreg Roach     * @param string $format
48d97083feSGreg Roach     *
49d97083feSGreg Roach     * @return string
50d97083feSGreg Roach     */
51d97083feSGreg Roach    public function isoFormat(string $format): string;
52d97083feSGreg Roach
53d97083feSGreg Roach    /**
54d97083feSGreg Roach     * @return string
55d97083feSGreg Roach     */
56d97083feSGreg Roach    public function toDateString(): string;
57d97083feSGreg Roach
58d97083feSGreg Roach    /**
59d97083feSGreg Roach     * @return string
60d97083feSGreg Roach     */
61d97083feSGreg Roach    public function toDateTimeString(): string;
62d97083feSGreg Roach
63d97083feSGreg Roach    /**
64*8e989043SGreg Roach     * @param TimestampInterface $timestamp
65d97083feSGreg Roach     *
66d97083feSGreg Roach     * @return int
67d97083feSGreg Roach     */
68*8e989043SGreg Roach    public function compare(TimestampInterface $timestamp): int;
69d97083feSGreg Roach
70d97083feSGreg Roach    /**
71d97083feSGreg Roach     * @param int $seconds
72d97083feSGreg Roach     *
736612c384SGreg Roach     * @return self
74d97083feSGreg Roach     */
757761cf05SGreg Roach    public function addSeconds(int $seconds): TimestampInterface;
76d97083feSGreg Roach
77d97083feSGreg Roach    /**
78d97083feSGreg Roach     * @param int $minutes
79d97083feSGreg Roach     *
806612c384SGreg Roach     * @return self
81d97083feSGreg Roach     */
827761cf05SGreg Roach    public function addMinutes(int $minutes): TimestampInterface;
83d97083feSGreg Roach
84d97083feSGreg Roach    /**
85d97083feSGreg Roach     * @param int $hours
86d97083feSGreg Roach     *
876612c384SGreg Roach     * @return self
88d97083feSGreg Roach     */
897761cf05SGreg Roach    public function addHours(int $hours): TimestampInterface;
90d97083feSGreg Roach
91d97083feSGreg Roach    /**
92d97083feSGreg Roach     * @param int $days
93d97083feSGreg Roach     *
946612c384SGreg Roach     * @return self
95d97083feSGreg Roach     */
967761cf05SGreg Roach    public function addDays(int $days): TimestampInterface;
97d97083feSGreg Roach
98d97083feSGreg Roach    /**
99d97083feSGreg Roach     * @param int $months
100d97083feSGreg Roach     *
1016612c384SGreg Roach     * @return self
102d97083feSGreg Roach     */
1037761cf05SGreg Roach    public function addMonths(int $months): TimestampInterface;
104d97083feSGreg Roach
105d97083feSGreg Roach    /**
106d97083feSGreg Roach     * @param int $years
107d97083feSGreg Roach     *
1086612c384SGreg Roach     * @return self
109d97083feSGreg Roach     */
1107761cf05SGreg Roach    public function addYears(int $years): TimestampInterface;
111d97083feSGreg Roach
112d97083feSGreg Roach    /**
113d97083feSGreg Roach     * @param int $seconds
114d97083feSGreg Roach     *
1156612c384SGreg Roach     * @return self
116d97083feSGreg Roach     */
1177761cf05SGreg Roach    public function subtractSeconds(int $seconds): TimestampInterface;
118d97083feSGreg Roach
119d97083feSGreg Roach    /**
120d97083feSGreg Roach     * @param int $minutes
121d97083feSGreg Roach     *
1226612c384SGreg Roach     * @return self
123d97083feSGreg Roach     */
1247761cf05SGreg Roach    public function subtractMinutes(int $minutes): TimestampInterface;
125d97083feSGreg Roach
126d97083feSGreg Roach    /**
127d97083feSGreg Roach     * @param int $hours
128d97083feSGreg Roach     *
1296612c384SGreg Roach     * @return self
130d97083feSGreg Roach     */
1317761cf05SGreg Roach    public function subtractHours(int $hours): TimestampInterface;
132d97083feSGreg Roach
133d97083feSGreg Roach    /**
134d97083feSGreg Roach     * @param int $days
135d97083feSGreg Roach     *
1366612c384SGreg Roach     * @return self
137d97083feSGreg Roach     */
1387761cf05SGreg Roach    public function subtractDays(int $days): TimestampInterface;
139d97083feSGreg Roach
140d97083feSGreg Roach    /**
141d97083feSGreg Roach     * @param int $months
142d97083feSGreg Roach     *
1436612c384SGreg Roach     * @return self
144d97083feSGreg Roach     */
1457761cf05SGreg Roach    public function subtractMonths(int $months): TimestampInterface;
146d97083feSGreg Roach
147d97083feSGreg Roach    /**
148d97083feSGreg Roach     * @param int $years
149d97083feSGreg Roach     *
1506612c384SGreg Roach     * @return self
151d97083feSGreg Roach     */
1527761cf05SGreg Roach    public function subtractYears(int $years): TimestampInterface;
153d97083feSGreg Roach
154d97083feSGreg Roach    /**
155d97083feSGreg Roach     * @return int
156d97083feSGreg Roach     */
157d97083feSGreg Roach    public function timestamp(): int;
158d97083feSGreg Roach}
159