Beispiel #1
0
function normaliser_date($date, $forcer_jour = false)
{
    $date = vider_date($date);
    if ($date) {
        if (preg_match("/^[0-9]{8,10}\$/", $date)) {
            $date = date("Y-m-d H:i:s", $date);
        }
        if (preg_match("#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?\$#", $date, $regs)) {
            $date = $regs[1] . "-00-00" . $regs[3];
        } else {
            if (preg_match("#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?\$#", $date, $regs)) {
                $date = preg_replace("@/@", "-", $regs[1]) . "-00" . $regs[3];
            } else {
                $date = date("Y-m-d H:i:s", strtotime($date));
            }
        }
        if ($forcer_jour) {
            $date = str_replace('-00', '-01', $date);
        }
    }
    return $date;
}
Beispiel #2
0
/**
 * Convertir une date en datetime 
 *
**/
function normaliser_date_datetime_dist($valeur, $options, &$erreur) {
	$defaut = '0000-00-00 00:00:00';
	if (!$valeur or $valeur==array('date'=>'','heure'=>'')) {
		return $defaut;
	}

	$date = str_replace('-', '/', $valeur); // formater en jj/mm/aaaa

	if (isset($options['heure'])) {
		$date .= (' ' . $options['heure'] . ':00');
	} else {
		$date .= ' 00:00:00';
	}

	include_spip('inc/filtres');
	if (!$date = recup_date($date)) {
		$erreur = "Impossible d'extraire la date de $date";
		return false;
	}

	if (!($date = mktime($date[3], $date[4], 0, (int)$date[1], (int)$date[2], (int)$date[0]))) {
		// mauvais format de date
		$erreur = "Impossible de normaliser la date...";
		return false;
	}

	$date = date("Y-m-d H:i:s", $date);
	$date = vider_date($date); // enlever les valeurs considerees comme nulles (1 1 1970, etc...)

	if (!$date) {
		$date = $defaut;
	}

	return $date;
}
Beispiel #3
0
     echo '<a href="case_det.php?case=' . $row['id_case'] . '" class="content_link">';
     echo '<img src="images/jimmac/stock_edit-16.png" width="16" height="16" alt="" border="0" />&nbsp;';
     echo '#' . $row['id_case'] . " - '" . $row['title'] . "'";
     echo '&nbsp;(' . _T('case_status_option_' . $row['status']) . ')';
     echo '</a></th>';
     echo "</tr>\n";
     $c = $row['id_case'];
 }
 echo "<tr>\n";
 // Id followup
 // echo '<td class="tbl_cont_' . $css . '"><img src="images/lcm/dotted_angle.gif" width="15" height="15" align="left" />&nbsp;' . $row['id_followup'] . '</td>';
 // Start date
 echo '<td class="tbl_cont_' . $css . '">' . format_date($row['date_start'], 'short') . '</td>';
 // Time
 echo '<td class="tbl_cont_' . $css . '">';
 $fu_date_end = vider_date($row['date_end']);
 if ($prefs['time_intervals'] == 'absolute') {
     if ($fu_date_end) {
         echo format_date($row['date_end'], 'short');
     }
 } else {
     $fu_time = $fu_date_end ? strtotime($row['date_end']) - strtotime($row['date_start']) : 0;
     echo format_time_interval_prefs($fu_time);
 }
 echo '</td>';
 // Author initials
 echo '<td class="tbl_cont_' . $css . '">' . get_person_initials($row) . '</td>';
 // Type
 echo '<td class="tbl_cont_' . $css . '">' . _Tkw('followups', $row['type']) . '</td>';
 // Description
 $short_description = get_fu_description($row);
Beispiel #4
0
function normaliser_date($date)
{
    if ($date) {
        $date = vider_date($date);
        if (preg_match("/^[0-9]{8,10}\$/", $date)) {
            $date = date("Y-m-d H:i:s", $date);
        }
        if (preg_match("/^([12][0-9]{3})([-\\/]00)?( [-0-9:]+)?\$/", $date, $regs)) {
            $date = $regs[1] . "-01-01" . $regs[3];
        } else {
            if (preg_match("/^([12][0-9]{3}[-\\/][01]?[0-9])([-\\/]00)?( [-0-9:]+)?\$/", $date, $regs)) {
                $date = preg_replace("/\\//", "-", $regs[1]) . "-01" . $regs[3];
            } else {
                if ($GLOBALS['flag_strtotime']) {
                    $date = date("Y-m-d H:i:s", strtotime($date));
                } else {
                    $date = preg_replace('/[^-0-9\\/: ]/', '', $date);
                }
            }
        }
    }
    return $date;
}
Beispiel #5
0
function show_listfu_item($item, $cpt, $screen = 'general')
{
    global $prefs;
    echo "<tr>\n";
    // Id case
    if ($screen == 'case') {
        echo '<td valign="top"><abbr title="' . $item['title'] . '">' . $item['id_case'] . '</abbr></td>';
    } else {
        echo '<td valign="top">' . $item['id_followup'] . '</abbr></td>';
    }
    // Start date
    echo '<td valign="top">' . format_date($item['date_start'], 'short') . '</td>';
    // Time
    echo '<td valign="top">';
    $fu_date_end = vider_date($item['date_end']);
    if ($prefs['time_intervals'] == 'absolute') {
        if ($fu_date_end) {
            echo format_date($item['date_end'], 'short');
        }
    } else {
        $fu_time = $fu_date_end ? strtotime($item['date_end']) - strtotime($item['date_start']) : 0;
        echo format_time_interval($fu_time, $prefs['time_intervals_notation'] == 'hours_only');
    }
    echo '</td>';
    // Author initials
    if ($screen != 'author') {
        echo '<td valign="top">' . get_person_initials($item) . '</td>';
    }
    // Type
    echo '<td valign="top">' . _Tkw('followups', $item['type']) . '</td>';
    // Description
    $cut_fu = isset($_REQUEST['more_fu_desc']) && $_REQUEST['more_fu_desc'] ? false : true;
    $short_description = get_fu_description($item, $cut_fu);
    if ($item['hidden'] == 'Y') {
        $short_description .= ' <img src="images/jimmac/stock_trash-16.png" ' . 'height="16" width="16" border="0" ' . 'title="' . _T('fu_info_is_deleted') . '" ' . 'alt="' . _T('fu_info_is_deleted') . '" />';
    }
    echo '<td valign="top">';
    echo '<a href="fu_det.php?followup=' . $item['id_followup'] . '" class="content_link">' . $short_description . '</a>';
    echo '</td>';
    echo "</tr>\n";
}