* @brief Wrapper for date selector, tailored for use in birthday fields.
*
* @param string $dob Date of Birth
+ * @param string $timezone
* @return string Formatted HTML
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \Exception
*/
- public static function getDateofBirthField($dob)
+ public static function getDateofBirthField(string $dob, string $timezone = 'UTC')
{
- $a = \get_app();
-
list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d');
if ($dob < '0000-01-01') {
$value = DateTimeFormat::utc(($year > 1000) ? $dob : '1000-' . $month . '-' . $day, 'Y-m-d');
}
- $age = (intval($value) ? self::getAgeByTimezone($value, $a->user["timezone"], $a->user["timezone"]) : "");
+ $age = (intval($value) ? self::getAgeByTimezone($value, $timezone, $timezone) : "");
$tpl = Renderer::getMarkupTemplate("field_input.tpl");
$o = Renderer::replaceMacros($tpl,
/**
* @brief Returns a date selector
*
- * @param string $min Unix timestamp of minimum date
- * @param string $max Unix timestap of maximum date
- * @param string $default Unix timestamp of default date
- * @param string $id ID and name of datetimepicker (defaults to "datetimepicker")
+ * @param DateTime $min Minimum date
+ * @param DateTime $max Maximum date
+ * @param DateTime $default Default date
+ * @param string $id ID and name of datetimepicker (defaults to "datetimepicker")
*
* @return string Parsed HTML output.
* @throws \Friendica\Network\HTTPException\InternalServerErrorException