4 |
david |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | Lesser General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
|
|
19 |
// | License along with this library; if not, write to the Free Software |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
22 |
// CVS : $Id: DAT_date.fonct.php,v 1.1 2004/09/10 15:01:00 jpm Exp $
|
|
|
23 |
/**
|
|
|
24 |
* API : date.
|
|
|
25 |
*
|
|
|
26 |
* Cette librairie contient des fonctions dédiées à la gestion des dates :
|
|
|
27 |
* formatage, transformations, conversions...
|
|
|
28 |
*
|
|
|
29 |
*@package API
|
|
|
30 |
*@subpackage Date
|
|
|
31 |
//Auteur original :
|
|
|
32 |
*@author Jean-Charles GRANGER <tela@vecteur.org>
|
|
|
33 |
//Autres auteurs :
|
|
|
34 |
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
|
|
|
35 |
*@author Jean-Pascal MILCENT <jpm@clapas.org>
|
|
|
36 |
*@copyright Tela-Botanica 2000-2004
|
|
|
37 |
*@version $Revision: 1.1 $ $Date: 2004/09/10 15:01:00 $
|
|
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
39 |
*/
|
|
|
40 |
|
|
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
42 |
// | ENTETE du PROGRAMME |
|
|
|
43 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
44 |
/*Mettre ici les inclusions de fichiers*/
|
|
|
45 |
|
|
|
46 |
// Compatibilité avec les anciennes versions :
|
|
|
47 |
/** FormateDateYYYYMMJJ() - Ancien nom de la fonction DAT_formaterDateYYYYMMJJ.
|
|
|
48 |
*
|
|
|
49 |
* Fontion obsolète! Veuiller utiliser DAT_formaterDateYYYYMMJJ().
|
|
|
50 |
*
|
|
|
51 |
* @param string date à formater.
|
|
|
52 |
* @return string date formatée.
|
|
|
53 |
*/
|
|
|
54 |
function FormateDateYYYYMMJJ($stamp_a_formater)
|
|
|
55 |
{
|
|
|
56 |
return DAT_formaterDateYYYYMMJJ($stamp_a_formater);
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
60 |
// | LISTE des FONCTIONS |
|
|
|
61 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
62 |
/*Mettre ici la liste de fonctions.*/
|
|
|
63 |
|
|
|
64 |
/** DAT_formaterDateYYYYMMJJ() - Formate en texte compréhensible une valeur au format yyyy.mm.jj
|
|
|
65 |
*
|
|
|
66 |
* Formate en texte compréhensible une valeur au format yyyy.mm.jj
|
|
|
67 |
* Exemples :
|
|
|
68 |
* - DAT_formaterDateYYYYMMJJ("1999"); --> "1999"
|
|
|
69 |
* - DAT_formaterDateYYYYMMJJ("1999.02"); --> "Février 1999"
|
|
|
70 |
* - DAT_formaterDateYYYYMMJJ("1999.11.03"); --> "3 Novembre 1999"
|
|
|
71 |
*
|
|
|
72 |
* @param string date à formater.
|
|
|
73 |
* @return string date formatée.
|
|
|
74 |
*/
|
|
|
75 |
function DAT_formaterDateYYYYMMJJ($stamp_a_formater)
|
|
|
76 |
{
|
|
|
77 |
ereg('[^0-9]', $stamp_a_formater, $chars);
|
|
|
78 |
|
|
|
79 |
if ($chars[0] == '') {
|
|
|
80 |
$chars[0] = '.';
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
$date_creation = explode($chars[0], $stamp_a_formater);
|
|
|
84 |
|
|
|
85 |
if (($date_creation[0] == 0) || (empty($date_creation[0]))) {
|
|
|
86 |
$date_creation[0] = '';
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
if (!empty($date_creation[1])){
|
|
|
90 |
switch($date_creation[1]){
|
|
|
91 |
case 1: $mois = 'Janvier ';
|
|
|
92 |
break;
|
|
|
93 |
case 2: $mois = 'Février ';
|
|
|
94 |
break;
|
|
|
95 |
case 3: $mois = 'Mars ';
|
|
|
96 |
break;
|
|
|
97 |
case 4: $mois = 'Avril ';
|
|
|
98 |
break;
|
|
|
99 |
case 5: $mois = 'Mai ';
|
|
|
100 |
break;
|
|
|
101 |
case 6: $mois = 'Juin';
|
|
|
102 |
break;
|
|
|
103 |
case 7: $mois = 'Juillet ';
|
|
|
104 |
break;
|
|
|
105 |
case 8: $mois = 'Août ';
|
|
|
106 |
break;
|
|
|
107 |
case 9: $mois = 'Septembre ';
|
|
|
108 |
break;
|
|
|
109 |
case 10: $mois = 'Octobre ';
|
|
|
110 |
break;
|
|
|
111 |
case 11: $mois = 'Novembre ';
|
|
|
112 |
break;
|
|
|
113 |
case 12: $mois = 'Décembre ';
|
|
|
114 |
break;
|
|
|
115 |
default: $mois = '';
|
|
|
116 |
}
|
|
|
117 |
} else {
|
|
|
118 |
$mois = '';
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
if (!empty($date_creation[2])){
|
|
|
122 |
if (($date_creation[2] == 0) || ($date_creation[2] == '')){
|
|
|
123 |
$jour = '';
|
|
|
124 |
} else {
|
|
|
125 |
$jour = $date_creation[2].' ';
|
|
|
126 |
}
|
|
|
127 |
} else{
|
|
|
128 |
$jour = '';
|
|
|
129 |
}
|
|
|
130 |
return $jour.$mois.$date_creation[0];
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
|
|
134 |
|
|
|
135 |
* $Log: DAT_date.fonct.php,v $
|
|
|
136 |
* Revision 1.1 2004/09/10 15:01:00 jpm
|
|
|
137 |
* Nouveau fichier remplaçeant lib.date.php.
|
|
|
138 |
* Contient des fonctions de manipulation de date.
|
|
|
139 |
*
|
|
|
140 |
*
|
|
|
141 |
* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
142 |
*/
|
|
|
143 |
?>
|