xref: /webtrees/app/Contracts/TimestampInterface.php (revision a81396241f8b2caf70988b1979e1927e5c8e9398)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2022 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Contracts;
21
22/**
23 * A localized date-time.
24 */
25interface TimestampInterface
26{
27    /**
28     * Convert a datetime to the user's Julian day number.
29     *
30     * @return int
31     */
32    public function julianDay(): int;
33
34    /**
35     * @return string
36     */
37    public function diffForHumans(): string;
38
39    /**
40     * @param string $format
41     *
42     * @return string
43     */
44    public function format(string $format): string;
45
46    /**
47     * @param string $format
48     *
49     * @return string
50     */
51    public function isoFormat(string $format): string;
52
53    /**
54     * @return string
55     */
56    public function toDateString(): string;
57
58    /**
59     * @return string
60     */
61    public function toDateTimeString(): string;
62
63    /**
64     * @param TimestampInterface $datetime
65     *
66     * @return int
67     */
68    public function compare(TimestampInterface $datetime): int;
69
70    /**
71     * @param int $seconds
72     *
73     * @return self
74     */
75    public function addSeconds(int $seconds): TimestampInterface;
76
77    /**
78     * @param int $minutes
79     *
80     * @return self
81     */
82    public function addMinutes(int $minutes): TimestampInterface;
83
84    /**
85     * @param int $hours
86     *
87     * @return self
88     */
89    public function addHours(int $hours): TimestampInterface;
90
91    /**
92     * @param int $days
93     *
94     * @return self
95     */
96    public function addDays(int $days): TimestampInterface;
97
98    /**
99     * @param int $months
100     *
101     * @return self
102     */
103    public function addMonths(int $months): TimestampInterface;
104
105    /**
106     * @param int $years
107     *
108     * @return self
109     */
110    public function addYears(int $years): TimestampInterface;
111
112    /**
113     * @param int $seconds
114     *
115     * @return self
116     */
117    public function subtractSeconds(int $seconds): TimestampInterface;
118
119    /**
120     * @param int $minutes
121     *
122     * @return self
123     */
124    public function subtractMinutes(int $minutes): TimestampInterface;
125
126    /**
127     * @param int $hours
128     *
129     * @return self
130     */
131    public function subtractHours(int $hours): TimestampInterface;
132
133    /**
134     * @param int $days
135     *
136     * @return self
137     */
138    public function subtractDays(int $days): TimestampInterface;
139
140    /**
141     * @param int $months
142     *
143     * @return self
144     */
145    public function subtractMonths(int $months): TimestampInterface;
146
147    /**
148     * @param int $years
149     *
150     * @return self
151     */
152    public function subtractYears(int $years): TimestampInterface;
153
154    /**
155     * @return int
156     */
157    public function timestamp(): int;
158}
159