public function BirthdaysBirthday::toString in Birthdays 7
Converts the value to a string.
@returns A string representation of the value.
File
- ./
birthdays_birthday.inc, line 160 - The BirthdaysBirthday class.
Class
- BirthdaysBirthday
- Converts between different data representations and do calculations on a birthday.
Code
public function toString($format = 'Y/m/d', $format_noyear = 'M d') {
if ($this
->isEmpty()) {
return '';
}
// Remove the year from the format, if none is given.
if (empty($this->value['year'])) {
$format_noyear = str_replace('[starsign]', '[s\\tarsig\\n]', $format_noyear);
$format_noyear = preg_replace('/([^djSFmMnt\\\\])/', '\\\\${1}', $format_noyear);
$result = format_date($this
->toUnixtime(), 'custom', $format_noyear);
}
else {
$format = str_replace('[starsign]', '[s\\tarsig\\n]', $format);
$format = str_replace('[age]', $this
->getCurrentAge(), $format);
$format = preg_replace('/([^dDjlNSwzWFmMntLoYy\\\\])/', '\\\\${1}', $format);
$result = format_date($this
->toUnixtime(), 'custom', $format);
}
return str_replace('[starsign]', t(ucfirst($this
->getStarsign())), $result);
}