forked from Wavyzz/dolibarr
Le format d'affichage des dates se base sur $conf->format_date_text_short
This commit is contained in:
@@ -419,23 +419,29 @@ function dolibarr_time_plus_duree($time,$duration_value,$duration_unit)
|
|||||||
/**
|
/**
|
||||||
\brief Formattage de la date en fonction de la langue $conf->langage
|
\brief Formattage de la date en fonction de la langue $conf->langage
|
||||||
\param time Date 'timestamp' ou format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
|
\param time Date 'timestamp' ou format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
|
||||||
\param format Format d'affichage de la date "%d %b %Y"
|
\param format Format d'affichage de la date ("%d %b %Y", "%d/%m/%Y", ...)
|
||||||
\return string Date format<61>e ou "?" si time nul
|
\return string Date format<61>e ou '?' si time null
|
||||||
*/
|
*/
|
||||||
function dolibarr_print_date($time,$format="%d %b %Y")
|
function dolibarr_print_date($time,$format='')
|
||||||
{
|
{
|
||||||
// Si date non d<>fini, on renvoie vide
|
global $conf;
|
||||||
if (! $time) return "?";
|
|
||||||
|
// Si format non d<>fini, on prend $conf->format_date_text_short
|
||||||
|
if (! $format) $format=$conf->format_date_text_short;
|
||||||
|
|
||||||
|
// Si date non d<>finie, on renvoie '?'
|
||||||
|
if (! $time) return '?';
|
||||||
|
|
||||||
// Analyse de la date
|
// Analyse de la date
|
||||||
if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?',$time,$reg)) {
|
if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?',$time,$reg))
|
||||||
// Date au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
|
{
|
||||||
|
// Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
|
||||||
$syear = $reg[1];
|
$syear = $reg[1];
|
||||||
$smonth = $reg[2];
|
$smonth = $reg[2];
|
||||||
$sday = $reg[3];
|
$sday = $reg[3];
|
||||||
$shour = $reg[4];
|
$shour = $reg[4];
|
||||||
$smin = $reg[5];
|
$smin = $reg[5];
|
||||||
if ($syear < 1970 && $_SERVER["WINDIR"])
|
if ($syear < 1970 && isset($_SERVER["WINDIR"]))
|
||||||
{
|
{
|
||||||
// Le formatage ne peut etre appliqu<71> car windows ne supporte pas la fonction
|
// Le formatage ne peut etre appliqu<71> car windows ne supporte pas la fonction
|
||||||
// mktime si l'ann<6E>e est inf<6E>rieur <20> 1970. On retourne un format fixe
|
// mktime si l'ann<6E>e est inf<6E>rieur <20> 1970. On retourne un format fixe
|
||||||
@@ -446,7 +452,8 @@ function dolibarr_print_date($time,$format="%d %b %Y")
|
|||||||
return strftime($format,mktime($shour,$smin,0,$smonth,$sday,$syear));
|
return strftime($format,mktime($shour,$smin,0,$smonth,$sday,$syear));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
// Date est un timestamps
|
// Date est un timestamps
|
||||||
return strftime($format,$time);
|
return strftime($format,$time);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user