]> git.mxchange.org Git - friendica.git/blobdiff - include/datetime.php
frio + core: some restructure in profiles.php + frio template for profiles settings
[friendica.git] / include / datetime.php
index 3a75690d2201c4641973518244c7abd687de1765..e27f54e09cd529015c924dec7ce3634e0127654f 100644 (file)
@@ -75,8 +75,8 @@ function select_timezone($current = 'America/Los_Angeles') {
  * 
  * Return a select using 'field_select_raw' template, with timezones
  * groupped (primarily) by continent
-.* arguments follow convetion as other field_* template array:
-.* 'name', 'label', $value, 'help'
+ * arguments follow convetion as other field_* template array:
+ * 'name', 'label', $value, 'help'
  * 
  * @param string $name Name of the selector
  * @param string $label Label for the selector
@@ -106,7 +106,7 @@ function field_timezone($name='timezone', $label='', $current = 'America/Los_Ang
  * @param string $fmt Output format recognised from php's DateTime class
  *   http://www.php.net/manual/en/datetime.format.php
  * 
- * @return string
+ * @return string Formatted date according to given format
  */
 function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") {
 
@@ -153,6 +153,7 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
        }
 
        $d->setTimeZone($to_obj);
+
        return($d->format($fmt));
 }
 
@@ -161,7 +162,7 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
  * @brief Wrapper for date selector, tailored for use in birthday fields.
  *
  * @param string $dob Date of Birth
- * @return string
+ * @return string Formatted html
  */
 function dob($dob) {
        list($year,$month,$day) = sscanf($dob,'%4d-%2d-%2d');
@@ -174,7 +175,18 @@ function dob($dob) {
        else
                $value = (($year) ? datetime_convert('UTC','UTC',$dob,'Y-m-d') : datetime_convert('UTC','UTC',$dob,'m-d'));
 
-       $o = '<input type="text" name="dob" value="' . $value . '" placeholder="' . t('YYYY-MM-DD or MM-DD') . '" />';
+       $age = ((intval($value)) ? age($value, $a->user["timezone"], $a->user["timezone"]) : "");
+
+       $o = replace_macros(get_markup_template("field_input.tpl"), array(
+               '$field' => array(
+                       'dob',
+                       t('Birthday:'),
+                       $value,
+                       (((intval($age)) > 0 ) ? t('Age: ') . $age : ""),
+                       '',
+                       'placeholder="' . t('YYYY-MM-DD or MM-DD') . '"'
+               )
+       ));
 
 //     if ($dob && $dob != '0000-00-00')
 //             $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),mktime(0,0,0,$month,$day,$year),'dob');
@@ -380,7 +392,7 @@ function relative_date($posted_date,$format = null) {
  * @param string $owner_tz (optional) Timezone of the person of interest
  * @param string $viewer_tz (optional) Timezone of the person viewing
  * 
- * @return int
+ * @return int Age in years
  */
 function age($dob,$owner_tz = '',$viewer_tz = '') {
        if(! intval($dob))