timeof) { case 'modification': $timestamp = $econf->req->last_modification_time(); break; case 'doc modification': $timestamp = $econf->doc->last_modification_time(); break; case 'clock': $timestamp = $econf->clock_time; break; default: $timestamp = $econf->req->request_time(); } switch ($econf->tz) { case 'utc': $str = gmstrftime($time_format, $timestamp); break; default: $str = strftime($time_format, $timestamp); } # Suppress leading '0' for month, hour, minute, second. if (strlen($str) == 2 && $str{0} === '0') { $str = $str{1}; } $out_elm->appendChild($out_elm->ownerDocument->createTextNode($str)); } function process_year_element($econf, $in_elm, $out_elm) { output_time($econf, '%Y', $out_elm); } function process_month_element($econf, $in_elm, $out_elm) { $fmt_attr_value = get_w2ml_attribute_value($in_elm, 'fmt'); switch ($fmt_attr_value) { case 'abbr': $fmt = '%b'; break; case 'name': $fmt = '%B'; break; default: log_error('Bad fmt value "'.$fmt_attr_value.'" for W2ML month element', $econf->log); case 'digit': case NULL: $fmt = '%m'; } output_time($econf, $fmt, $out_elm); } function process_day_element($econf, $in_elm, $out_elm) { $fmt_attr_value = get_w2ml_attribute_value($in_elm, 'fmt'); switch ($fmt_attr_value) { case 'abbr': $fmt = '%a'; break; case 'name': $fmt = '%A'; break; default: log_error('Bad fmt value "'.$fmt_attr_value.'" for W2ML day element', $econf->log); case 'digit': case NULL: $fmt = '%d'; } output_time($econf, $fmt, $out_elm); } function process_ampm_element($econf, $in_elm, $out_elm) { output_time($econf, '%p', $out_elm); } function process_hour_element($econf, $in_elm, $out_elm) { $fmt_attr_value = get_w2ml_attribute_value($in_elm, 'fmt'); # Use === to avoid type conversion. if ($fmt_attr_value === '12') { $fmt = '%I'; } else { if ($fmt_attr_value !== '24' && $fmt_attr_value !== NULL) { log_error('Bad fmt value "'.$fmt_attr_value.'" for W2ML hour element', $econf->log); } $fmt = '%H'; } output_time($econf, $fmt, $out_elm); } function process_minute_element($econf, $in_elm, $out_elm) { output_time($econf, '%M', $out_elm); } function process_second_element($econf, $in_elm, $out_elm) { output_time($econf, '%S', $out_elm); } function process_tz_element($econf, $in_elm, $out_elm) { $fmt_attr_value = get_w2ml_attribute_value($in_elm, 'fmt'); switch ($fmt_attr_value) { case 'num': $fmt = '%z'; break; default: log_error('Bad fmt value "'.$fmt_attr_value.'" for W2ML tz element', $econf->log); case NULL: case 'abbr': $fmt = '%Z'; } output_time($econf, $fmt, $out_elm); } function process_time_element($econf, $in_elm, $out_elm) { $fmt_attr_value = get_w2ml_attribute_value($in_elm, 'fmt'); switch ($fmt_attr_value) { case 'rfc822': $fmt = '%a, %d %b %Y %H:%M:%S %z'; break; default: log_error('Bad fmt value "'.$fmt_attr_value.'" for W2ML time element', $econf->log); case NULL: case 'local': $fmt = '%c'; } output_time($econf, $fmt, $out_elm); } function process_sleep_element($econf, $in_elm, $out_elm) { $str = $in_elm->textContent; $duration = str_to_duration($str); if ($duration === NULL) { log_error('Invalid time duration format "'.$str.'" for sleep element', $econf->log); } else { usleep($duration); } } ?>