Replace remaining occurrences of "0001-01-01" with DBA::NULL_DATE

This commit is contained in:
Hypolite Petovan 2018-11-21 23:53:45 -05:00
parent cf1c63fcc2
commit d71e856535
6 changed files with 11 additions and 12 deletions

View file

@ -107,7 +107,7 @@ function hovercard_content()
'about' => $contact['about'],
'network' => Strings::formatNetworkName($contact['network'], $contact['url']),
'tags' => $contact['keywords'],
'bd' => $contact['birthday'] <= '0001-01-01' ? '' : $contact['birthday'],
'bd' => $contact['birthday'] <= DBA::NULL_DATE ? '' : $contact['birthday'],
'account_type' => Contact::getAccountType($contact),
'actions' => $actions,
];

View file

@ -216,7 +216,7 @@ function profiles_post(App $a) {
} else {
$ignore_year = false;
}
if (!in_array($dob, ['0000-00-00', '0001-01-01'])) {
if (!in_array($dob, ['0000-00-00', DBA::NULL_DATE])) {
if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
$ignore_year = true;
$dob = substr($dob, 5);

View file

@ -740,7 +740,7 @@ class Contact extends BaseObject
// "bd" always contains the upcoming birthday of a contact.
// "birthday" might contain the birthday including the year of birth.
if ($profile["birthday"] > '0001-01-01') {
if ($profile["birthday"] > DBA::NULL_DATE) {
$bd_timestamp = strtotime($profile["birthday"]);
$month = date("m", $bd_timestamp);
$day = date("d", $bd_timestamp);
@ -757,7 +757,7 @@ class Contact extends BaseObject
$profile["bd"] = ( ++$current_year) . "-" . $month . "-" . $day;
}
} else {
$profile["bd"] = '0001-01-01';
$profile["bd"] = DBA::NULL_DATE;
}
} else {
$profile = $default;
@ -794,7 +794,7 @@ class Contact extends BaseObject
$profile["location"] = "";
$profile["about"] = "";
$profile["gender"] = "";
$profile["birthday"] = '0001-01-01';
$profile["birthday"] = DBA::NULL_DATE;
}
$cache[$url][$uid] = $profile;

View file

@ -864,7 +864,7 @@ class GContact
'location' => $contact['location'], 'about' => $contact['about']];
// Don't update the birthday field if not set or invalid
if (empty($contact['birthday']) || ($contact['birthday'] < '0001-01-01')) {
if (empty($contact['birthday']) || ($contact['birthday'] <= DBA::NULL_DATE)) {
unset($fields['bd']);
}

View file

@ -749,7 +749,7 @@ class Profile
$profile['gender'] = [L10n::t('Gender:'), $a->profile['gender']];
}
if (($a->profile['dob']) && ($a->profile['dob'] > '0001-01-01')) {
if (!empty($a->profile['dob']) && $a->profile['dob'] > DBA::NULL_DATE) {
$year_bd_format = L10n::t('j F, Y');
$short_bd_format = L10n::t('j F');
@ -763,7 +763,7 @@ class Profile
}
if (!empty($a->profile['dob'])
&& $a->profile['dob'] > '0001-01-01'
&& $a->profile['dob'] > DBA::NULL_DATE
&& $age = Temporal::getAgeByTimezone($a->profile['dob'], $a->profile['timezone'], '')
) {
$profile['age'] = [L10n::t('Age:'), $age];

View file

@ -16,7 +16,6 @@ use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
@ -690,7 +689,7 @@ class DFRN
XML::addElement($doc, $author, "poco:displayName", $profile["name"]);
XML::addElement($doc, $author, "poco:updated", $namdate);
if (trim($profile["dob"]) > '0001-01-01') {
if (trim($profile["dob"]) > DBA::NULL_DATE) {
XML::addElement($doc, $author, "poco:birthday", "0000-".date("m-d", strtotime($profile["dob"])));
}
@ -1722,9 +1721,9 @@ class DFRN
// "poco:birthday" is the birthday in the format "yyyy-mm-dd"
$value = XML::getFirstNodeValue($xpath, $element . "/poco:birthday/text()", $context);
if (!in_array($value, ["", "0000-00-00", "0001-01-01"])) {
if (!in_array($value, ["", "0000-00-00", DBA::NULL_DATE])) {
$bdyear = date("Y");
$value = str_replace("0000", $bdyear, $value);
$value = str_replace(["0000", "0001"], $bdyear, $value);
if (strtotime($value) < time()) {
$value = str_replace($bdyear, $bdyear + 1, $value);