| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Hook; |
| 4 | |
| 5 | use DateInterval; |
| 6 | use MediaWiki\Language\Language; |
| 7 | use MediaWiki\User\User; |
| 8 | use MediaWiki\Utils\MWTimestamp; |
| 9 | |
| 10 | /** |
| 11 | * This is a hook handler interface, see docs/Hooks.md. |
| 12 | * Use the hook name "GetRelativeTimestamp" to register handlers implementing this interface. |
| 13 | * |
| 14 | * @stable to implement |
| 15 | * @ingroup Hooks |
| 16 | */ |
| 17 | interface GetRelativeTimestampHook { |
| 18 | /** |
| 19 | * Use this hook to pre-emptively override the relative timestamp generated |
| 20 | * by MWTimestamp::getRelativeTimestamp(). |
| 21 | * |
| 22 | * @since 1.35 |
| 23 | * |
| 24 | * @param string &$output String for the output timestamp |
| 25 | * @param DateInterval &$diff Difference between the timestamps |
| 26 | * @param MWTimestamp $timestamp Current (user-adjusted) timestamp |
| 27 | * @param MWTimestamp $relativeTo Relative (user-adjusted) timestamp |
| 28 | * @param User $user User whose preferences are being used to make timestamp |
| 29 | * @param Language $lang Language that will be used to render the timestamp |
| 30 | * @return bool|void True or no return value to continue, or false to use the custom output |
| 31 | */ |
| 32 | public function onGetRelativeTimestamp( &$output, &$diff, $timestamp, |
| 33 | $relativeTo, $user, $lang |
| 34 | ); |
| 35 | } |