8use Wikimedia\Timestamp\ConvertibleTimestamp;
9use Wikimedia\Timestamp\TimestampException;
60 $this->defaultFormat = $options[
'defaultFormat'] ??
'ConvertibleTimestamp';
61 $this->stringifyFormat = $options[
'stringifyFormat'] ?? TS_ISO_8601;
64 public function validate( $name, $value, array $settings, array $options ) {
67 $this->callbacks->recordCondition(
75 $timestamp =
new ConvertibleTimestamp( $value ===
'now' ?
false : $value );
76 }
catch ( TimestampException $ex ) {
82 case 'ConvertibleTimestamp':
87 return $timestamp->timestamp;
90 return $timestamp->getTimestamp( $format );
94 public function stringifyValue( $name, $value, array $settings, array $options ) {
95 if ( !$value instanceof ConvertibleTimestamp ) {
96 $value =
new ConvertibleTimestamp( $value );
98 return $value->getTimestamp( $this->stringifyFormat );