X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fdatetime.php;h=d44e995cfaf5e7996ef532276dac15f5cfc43034;hb=64d0616762efcff413a335f2fdde4d8219d44895;hp=a056eaa60e34492158f09fc4bd19d29869655a17;hpb=f4a1820110e6c85f91c7a3dbdada35f76be83f36;p=friendica.git
diff --git a/include/datetime.php b/include/datetime.php
old mode 100644
new mode 100755
index a056eaa60e..d44e995cfa
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -15,7 +15,6 @@ function timezone_cmp($a, $b) {
}}
// emit a timezone selector grouped (primarily) by continent
-
if(! function_exists('select_timezone')) {
function select_timezone($current = 'America/Los_Angeles') {
@@ -55,6 +54,23 @@ function select_timezone($current = 'America/Los_Angeles') {
return $o;
}}
+// 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'
+if (!function_exists('field_timezone')){
+function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help){
+ $options = select_timezone($current);
+ $options = str_replace('','', $options);
+
+ $tpl = get_markup_template('field_select_raw.tpl');
+ return replace_macros($tpl, array(
+ '$field' => array($name, $label, $current, $help, $options),
+ ));
+
+}}
+
// General purpose date parse/convert function.
// $from = source timezone
// $to = dest timezone
@@ -84,12 +100,47 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
function dob($dob) {
list($year,$month,$day) = sscanf($dob,'%4d-%2d-%2d');
$y = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
- $o = datesel('',1920,$y,true,$year,$month,$day);
+ $f = get_config('system','birthday_input_format');
+ if(! $f)
+ $f = 'ymd';
+ $o = datesel($f,'',1920,$y,true,$year,$month,$day);
+ return $o;
+}
+
+
+function datesel_format($f) {
+
+ $o = '';
+
+ if(strlen($f)) {
+ for($x = 0; $x < strlen($f); $x ++) {
+ switch($f[$x]) {
+ case 'y':
+ if(strlen($o))
+ $o .= '-';
+ $o .= t('year');
+ break;
+ case 'm':
+ if(strlen($o))
+ $o .= '-';
+ $o .= t('month');
+ break;
+ case 'd':
+ if(strlen($o))
+ $o .= '-';
+ $o .= t('day');
+ break;
+ default:
+ break;
+ }
+ }
+ }
return $o;
}
// returns a date selector.
+// $f = format string, e.g. 'ymd' or 'mdy'
// $pre = prefix (if needed) for HTML name and class fields
// $ymin = first year shown in selector dropdown
// $ymax = last year shown in selector dropdown
@@ -99,40 +150,52 @@ function dob($dob) {
// $d = already selected day
if(! function_exists('datesel')) {
-function datesel($pre,$ymin,$ymax,$allow_blank,$y,$m,$d) {
+function datesel($f,$pre,$ymin,$ymax,$allow_blank,$y,$m,$d) {
$o = '';
- $o .= "