1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2021 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 $this 74 */ 75 public function addSeconds(int $seconds): static; 76 77 /** 78 * @param int $minutes 79 * 80 * @return $this 81 */ 82 public function addMinutes(int $minutes): static; 83 84 /** 85 * @param int $hours 86 * 87 * @return $this 88 */ 89 public function addHours(int $hours): static; 90 91 /** 92 * @param int $days 93 * 94 * @return $this 95 */ 96 public function addDays(int $days): static; 97 98 /** 99 * @param int $months 100 * 101 * @return $this 102 */ 103 public function addMonths(int $months): static; 104 105 /** 106 * @param int $years 107 * 108 * @return $this 109 */ 110 public function addYears(int $years): static; 111 112 /** 113 * @param int $seconds 114 * 115 * @return $this 116 */ 117 public function subtractSeconds(int $seconds): static; 118 119 /** 120 * @param int $minutes 121 * 122 * @return $this 123 */ 124 public function subtractMinutes(int $minutes): static; 125 126 /** 127 * @param int $hours 128 * 129 * @return $this 130 */ 131 public function subtractHours(int $hours): static; 132 133 /** 134 * @param int $days 135 * 136 * @return $this 137 */ 138 public function subtractDays(int $days): static; 139 140 /** 141 * @param int $months 142 * 143 * @return $this 144 */ 145 public function subtractMonths(int $months): static; 146 147 /** 148 * @param int $years 149 * 150 * @return $this 151 */ 152 public function subtractYears(int $years): static; 153 154 /** 155 * @return int 156 */ 157 public function timestamp(): int; 158} 159