fix(Sharing): Improve date error messages

Signed-off-by: provokateurin <kate@provokateurin.de>
pull/62598/head
provokateurin 3 weeks ago
parent af8c47a5aa
commit eaa2d89e7f
No known key found for this signature in database
  1. 8
      lib/public/Sharing/Property/ADateSharePropertyType.php

@ -46,15 +46,17 @@ abstract class ADateSharePropertyType implements ISharePropertyType {
}
if ($date === false) {
return $l10nFactory->get(Application::APP_ID)->t('Invalid ISO date: %s', [$value]);
return $l10nFactory->get(Application::APP_ID)->t('Invalid ISO8601 date: %s', [$value]);
}
if (($minDate = $this->getMinDate($share)) instanceof DateTimeImmutable && $date->diff($minDate)->invert === 0) {
return $l10nFactory->get(Application::APP_ID)->t('Date needs to be after %1$s: %2$s', [$minDate->format(DateTimeInterface::ATOM), $value]);
$l10n = $l10nFactory->get(Application::APP_ID);
return $l10n->t('Date needs to be after %s', [$l10n->l('datetime', $minDate)]);
}
if (($maxDate = $this->getMaxDate($share)) instanceof DateTimeImmutable && $date->diff($maxDate)->invert === 1) {
return $l10nFactory->get(Application::APP_ID)->t('Date needs to be before %1$s: %2$s', [$maxDate->format(DateTimeInterface::ATOM), $value]);
$l10n = $l10nFactory->get(Application::APP_ID);
return $l10n->t('Date needs to be before %s', [$l10n->l('datetime', $maxDate)]);
}
return true;

Loading…
Cancel
Save