@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | * Date au format SQL tel que `2008-04-01` |
| 37 | 37 | **/ |
| 38 | 38 | function extraire_date($texte) { |
| 39 | - // format = 2001-08 |
|
| 40 | - if (preg_match(",([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),", $texte, $regs)) { |
|
| 41 | - return $regs[1] . "-" . sprintf("%02d", $regs[2]) . "-01"; |
|
| 42 | - } |
|
| 39 | + // format = 2001-08 |
|
| 40 | + if (preg_match(",([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),", $texte, $regs)) { |
|
| 41 | + return $regs[1] . "-" . sprintf("%02d", $regs[2]) . "-01"; |
|
| 42 | + } |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -61,29 +61,29 @@ discard block |
||
| 61 | 61 | * - une chaîne vide si la date est considérée nulle |
| 62 | 62 | **/ |
| 63 | 63 | function normaliser_date($date, $forcer_jour = false) { |
| 64 | - $date = vider_date($date); |
|
| 65 | - if ($date) { |
|
| 66 | - if (preg_match("/^[0-9]{8,10}$/", $date)) { |
|
| 67 | - $date = date("Y-m-d H:i:s", $date); |
|
| 68 | - } |
|
| 69 | - if (preg_match("#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 70 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 71 | - $date = $regs[1] . "-00-00" . $regs[3]; |
|
| 72 | - } else { |
|
| 73 | - if (preg_match("#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 74 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 75 | - $date = preg_replace("@/@", "-", $regs[1]) . "-00" . $regs[3]; |
|
| 76 | - } else { |
|
| 77 | - $date = date("Y-m-d H:i:s", strtotime($date)); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ($forcer_jour) { |
|
| 82 | - $date = str_replace('-00', '-01', $date); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - return $date; |
|
| 64 | + $date = vider_date($date); |
|
| 65 | + if ($date) { |
|
| 66 | + if (preg_match("/^[0-9]{8,10}$/", $date)) { |
|
| 67 | + $date = date("Y-m-d H:i:s", $date); |
|
| 68 | + } |
|
| 69 | + if (preg_match("#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 70 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 71 | + $date = $regs[1] . "-00-00" . $regs[3]; |
|
| 72 | + } else { |
|
| 73 | + if (preg_match("#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 74 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 75 | + $date = preg_replace("@/@", "-", $regs[1]) . "-00" . $regs[3]; |
|
| 76 | + } else { |
|
| 77 | + $date = date("Y-m-d H:i:s", strtotime($date)); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ($forcer_jour) { |
|
| 82 | + $date = str_replace('-00', '-01', $date); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + return $date; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -96,21 +96,21 @@ discard block |
||
| 96 | 96 | * - Une chaine vide |
| 97 | 97 | **/ |
| 98 | 98 | function vider_date($letexte, $verif_format_date = false) { |
| 99 | - if (!$verif_format_date |
|
| 100 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 101 | - preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/", $letexte))) { |
|
| 102 | - |
|
| 103 | - if (strncmp("0000-00-00", $letexte, 10) == 0) { |
|
| 104 | - return ''; |
|
| 105 | - } |
|
| 106 | - if (strncmp("0001-01-01", $letexte, 10) == 0) { |
|
| 107 | - return ''; |
|
| 108 | - } |
|
| 109 | - if (strncmp("1970-01-01", $letexte, 10) == 0) { |
|
| 110 | - return ''; |
|
| 111 | - } // eviter le bug GMT-1 |
|
| 112 | - } |
|
| 113 | - return $letexte; |
|
| 99 | + if (!$verif_format_date |
|
| 100 | + or (in_array(strlen($letexte), [10,19]) and |
|
| 101 | + preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/", $letexte))) { |
|
| 102 | + |
|
| 103 | + if (strncmp("0000-00-00", $letexte, 10) == 0) { |
|
| 104 | + return ''; |
|
| 105 | + } |
|
| 106 | + if (strncmp("0001-01-01", $letexte, 10) == 0) { |
|
| 107 | + return ''; |
|
| 108 | + } |
|
| 109 | + if (strncmp("1970-01-01", $letexte, 10) == 0) { |
|
| 110 | + return ''; |
|
| 111 | + } // eviter le bug GMT-1 |
|
| 112 | + } |
|
| 113 | + return $letexte; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -126,14 +126,14 @@ discard block |
||
| 126 | 126 | **/ |
| 127 | 127 | function recup_heure($date) { |
| 128 | 128 | |
| 129 | - static $d = array(0, 0, 0); |
|
| 130 | - if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 131 | - return $d; |
|
| 132 | - } |
|
| 129 | + static $d = array(0, 0, 0); |
|
| 130 | + if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 131 | + return $d; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - array_shift($r); |
|
| 134 | + array_shift($r); |
|
| 135 | 135 | |
| 136 | - return $r; |
|
| 136 | + return $r; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | * @return int heures, sinon 0 |
| 148 | 148 | **/ |
| 149 | 149 | function heures($numdate) { |
| 150 | - $date_array = recup_heure($numdate); |
|
| 151 | - if ($date_array) { |
|
| 152 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 153 | - } |
|
| 150 | + $date_array = recup_heure($numdate); |
|
| 151 | + if ($date_array) { |
|
| 152 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - return $heures; |
|
| 155 | + return $heures; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | * @return int minutes, sinon 0 |
| 167 | 167 | **/ |
| 168 | 168 | function minutes($numdate) { |
| 169 | - $date_array = recup_heure($numdate); |
|
| 170 | - if ($date_array) { |
|
| 171 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 172 | - } |
|
| 169 | + $date_array = recup_heure($numdate); |
|
| 170 | + if ($date_array) { |
|
| 171 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - return $minutes; |
|
| 174 | + return $minutes; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -185,12 +185,12 @@ discard block |
||
| 185 | 185 | * @return int secondes, sinon 0 |
| 186 | 186 | **/ |
| 187 | 187 | function secondes($numdate) { |
| 188 | - $date_array = recup_heure($numdate); |
|
| 189 | - if ($date_array) { |
|
| 190 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 191 | - } |
|
| 188 | + $date_array = recup_heure($numdate); |
|
| 189 | + if ($date_array) { |
|
| 190 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - return $secondes; |
|
| 193 | + return $secondes; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | * @return string L'heure formatée dans la langue en cours. |
| 210 | 210 | **/ |
| 211 | 211 | function heures_minutes($numdate, $forme='') { |
| 212 | - if ($forme !='abbr') { |
|
| 213 | - return _T('date_fmt_heures_minutes', array('h' => heures($numdate), 'm' => minutes($numdate))); |
|
| 214 | - } |
|
| 215 | - else { |
|
| 216 | - return _T('date_fmt_heures_minutes_court', array('h' => heures($numdate), 'm' => minutes($numdate))); |
|
| 217 | - } |
|
| 212 | + if ($forme !='abbr') { |
|
| 213 | + return _T('date_fmt_heures_minutes', array('h' => heures($numdate), 'm' => minutes($numdate))); |
|
| 214 | + } |
|
| 215 | + else { |
|
| 216 | + return _T('date_fmt_heures_minutes_court', array('h' => heures($numdate), 'm' => minutes($numdate))); |
|
| 217 | + } |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -239,57 +239,57 @@ discard block |
||
| 239 | 239 | * @return array [année, mois, jour, heures, minutes, secondes] |
| 240 | 240 | **/ |
| 241 | 241 | function recup_date($numdate, $forcer_jour = true) { |
| 242 | - if (!$numdate) { |
|
| 243 | - return ''; |
|
| 244 | - } |
|
| 245 | - $heures = $minutes = $secondes = 0; |
|
| 246 | - if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 247 | - $jour = $regs[1]; |
|
| 248 | - $mois = $regs[2]; |
|
| 249 | - $annee = $regs[3]; |
|
| 250 | - if ($annee < 90) { |
|
| 251 | - $annee = 2000 + $annee; |
|
| 252 | - } elseif ($annee < 100) { |
|
| 253 | - $annee = 1900 + $annee; |
|
| 254 | - } |
|
| 255 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 256 | - |
|
| 257 | - } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 258 | - $annee = $regs[1]; |
|
| 259 | - $mois = $regs[2]; |
|
| 260 | - $jour = $regs[3]; |
|
| 261 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 262 | - } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 263 | - $annee = $regs[1]; |
|
| 264 | - $mois = $regs[2]; |
|
| 265 | - $jour = ''; |
|
| 266 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 267 | - } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 268 | - $annee = $regs[1]; |
|
| 269 | - $mois = $regs[2]; |
|
| 270 | - $jour = $regs[3]; |
|
| 271 | - $heures = $regs[4]; |
|
| 272 | - $minutes = $regs[5]; |
|
| 273 | - $secondes = $regs[6]; |
|
| 274 | - } else { |
|
| 275 | - $annee = $mois = $jour = ''; |
|
| 276 | - } |
|
| 277 | - if ($annee > 4000) { |
|
| 278 | - $annee -= 9000; |
|
| 279 | - } |
|
| 280 | - if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 281 | - $jour = substr($jour, 1); |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - if ($forcer_jour and $jour == '0') { |
|
| 285 | - $jour = '1'; |
|
| 286 | - } |
|
| 287 | - if ($forcer_jour and $mois == '0') { |
|
| 288 | - $mois = '1'; |
|
| 289 | - } |
|
| 290 | - if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 291 | - return array($annee, $mois, $jour, $heures, $minutes, $secondes); |
|
| 292 | - } |
|
| 242 | + if (!$numdate) { |
|
| 243 | + return ''; |
|
| 244 | + } |
|
| 245 | + $heures = $minutes = $secondes = 0; |
|
| 246 | + if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 247 | + $jour = $regs[1]; |
|
| 248 | + $mois = $regs[2]; |
|
| 249 | + $annee = $regs[3]; |
|
| 250 | + if ($annee < 90) { |
|
| 251 | + $annee = 2000 + $annee; |
|
| 252 | + } elseif ($annee < 100) { |
|
| 253 | + $annee = 1900 + $annee; |
|
| 254 | + } |
|
| 255 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 256 | + |
|
| 257 | + } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 258 | + $annee = $regs[1]; |
|
| 259 | + $mois = $regs[2]; |
|
| 260 | + $jour = $regs[3]; |
|
| 261 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 262 | + } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 263 | + $annee = $regs[1]; |
|
| 264 | + $mois = $regs[2]; |
|
| 265 | + $jour = ''; |
|
| 266 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 267 | + } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 268 | + $annee = $regs[1]; |
|
| 269 | + $mois = $regs[2]; |
|
| 270 | + $jour = $regs[3]; |
|
| 271 | + $heures = $regs[4]; |
|
| 272 | + $minutes = $regs[5]; |
|
| 273 | + $secondes = $regs[6]; |
|
| 274 | + } else { |
|
| 275 | + $annee = $mois = $jour = ''; |
|
| 276 | + } |
|
| 277 | + if ($annee > 4000) { |
|
| 278 | + $annee -= 9000; |
|
| 279 | + } |
|
| 280 | + if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 281 | + $jour = substr($jour, 1); |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + if ($forcer_jour and $jour == '0') { |
|
| 285 | + $jour = '1'; |
|
| 286 | + } |
|
| 287 | + if ($forcer_jour and $mois == '0') { |
|
| 288 | + $mois = '1'; |
|
| 289 | + } |
|
| 290 | + if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 291 | + return array($annee, $mois, $jour, $heures, $minutes, $secondes); |
|
| 292 | + } |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | * La date relative ou complète |
| 317 | 317 | **/ |
| 318 | 318 | function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */) { |
| 319 | - return sinon( |
|
| 320 | - date_relative($date, $decalage_maxi), |
|
| 321 | - affdate_heure($date) |
|
| 322 | - ); |
|
| 319 | + return sinon( |
|
| 320 | + date_relative($date, $decalage_maxi), |
|
| 321 | + affdate_heure($date) |
|
| 322 | + ); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -352,85 +352,85 @@ discard block |
||
| 352 | 352 | **/ |
| 353 | 353 | function date_relative($date, $decalage_maxi = 0, $ref_date = null) { |
| 354 | 354 | |
| 355 | - if (is_null($ref_date)) { |
|
| 356 | - $ref_time = time(); |
|
| 357 | - } else { |
|
| 358 | - $ref_time = strtotime($ref_date); |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - if (!$date) { |
|
| 362 | - return; |
|
| 363 | - } |
|
| 364 | - $decal = date("U", $ref_time) - date("U", strtotime($date)); |
|
| 365 | - |
|
| 366 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 367 | - return ''; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - if ($decal < 0) { |
|
| 371 | - $il_y_a = "date_dans"; |
|
| 372 | - $decal = -1 * $decal; |
|
| 373 | - } else { |
|
| 374 | - $il_y_a = "date_il_y_a"; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - if ($decal > 3600 * 24 * 30 * 6) { |
|
| 378 | - return affdate_court($date); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - if ($decal > 3600 * 24 * 30) { |
|
| 382 | - $mois = floor($decal / (3600 * 24 * 30)); |
|
| 383 | - if ($mois < 2) { |
|
| 384 | - $delai = "$mois " . _T("date_un_mois"); |
|
| 385 | - } else { |
|
| 386 | - $delai = "$mois " . _T("date_mois"); |
|
| 387 | - } |
|
| 388 | - } else { |
|
| 389 | - if ($decal > 3600 * 24 * 7) { |
|
| 390 | - $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 391 | - if ($semaines < 2) { |
|
| 392 | - $delai = "$semaines " . _T("date_une_semaine"); |
|
| 393 | - } else { |
|
| 394 | - $delai = "$semaines " . _T("date_semaines"); |
|
| 395 | - } |
|
| 396 | - } else { |
|
| 397 | - if ($decal > 3600 * 24) { |
|
| 398 | - $jours = floor($decal / (3600 * 24)); |
|
| 399 | - if ($jours < 2) { |
|
| 400 | - return $il_y_a == "date_dans" ? _T("date_demain") : _T("date_hier"); |
|
| 401 | - } else { |
|
| 402 | - $delai = "$jours " . _T("date_jours"); |
|
| 403 | - } |
|
| 404 | - } else { |
|
| 405 | - if ($decal >= 3600) { |
|
| 406 | - $heures = floor($decal / 3600); |
|
| 407 | - if ($heures < 2) { |
|
| 408 | - $delai = "$heures " . _T("date_une_heure"); |
|
| 409 | - } else { |
|
| 410 | - $delai = "$heures " . _T("date_heures"); |
|
| 411 | - } |
|
| 412 | - } else { |
|
| 413 | - if ($decal >= 60) { |
|
| 414 | - $minutes = floor($decal / 60); |
|
| 415 | - if ($minutes < 2) { |
|
| 416 | - $delai = "$minutes " . _T("date_une_minute"); |
|
| 417 | - } else { |
|
| 418 | - $delai = "$minutes " . _T("date_minutes"); |
|
| 419 | - } |
|
| 420 | - } else { |
|
| 421 | - $secondes = ceil($decal); |
|
| 422 | - if ($secondes < 2) { |
|
| 423 | - $delai = "$secondes " . _T("date_une_seconde"); |
|
| 424 | - } else { |
|
| 425 | - $delai = "$secondes " . _T("date_secondes"); |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - return _T($il_y_a, array("delai" => $delai)); |
|
| 355 | + if (is_null($ref_date)) { |
|
| 356 | + $ref_time = time(); |
|
| 357 | + } else { |
|
| 358 | + $ref_time = strtotime($ref_date); |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + if (!$date) { |
|
| 362 | + return; |
|
| 363 | + } |
|
| 364 | + $decal = date("U", $ref_time) - date("U", strtotime($date)); |
|
| 365 | + |
|
| 366 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 367 | + return ''; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + if ($decal < 0) { |
|
| 371 | + $il_y_a = "date_dans"; |
|
| 372 | + $decal = -1 * $decal; |
|
| 373 | + } else { |
|
| 374 | + $il_y_a = "date_il_y_a"; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + if ($decal > 3600 * 24 * 30 * 6) { |
|
| 378 | + return affdate_court($date); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + if ($decal > 3600 * 24 * 30) { |
|
| 382 | + $mois = floor($decal / (3600 * 24 * 30)); |
|
| 383 | + if ($mois < 2) { |
|
| 384 | + $delai = "$mois " . _T("date_un_mois"); |
|
| 385 | + } else { |
|
| 386 | + $delai = "$mois " . _T("date_mois"); |
|
| 387 | + } |
|
| 388 | + } else { |
|
| 389 | + if ($decal > 3600 * 24 * 7) { |
|
| 390 | + $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 391 | + if ($semaines < 2) { |
|
| 392 | + $delai = "$semaines " . _T("date_une_semaine"); |
|
| 393 | + } else { |
|
| 394 | + $delai = "$semaines " . _T("date_semaines"); |
|
| 395 | + } |
|
| 396 | + } else { |
|
| 397 | + if ($decal > 3600 * 24) { |
|
| 398 | + $jours = floor($decal / (3600 * 24)); |
|
| 399 | + if ($jours < 2) { |
|
| 400 | + return $il_y_a == "date_dans" ? _T("date_demain") : _T("date_hier"); |
|
| 401 | + } else { |
|
| 402 | + $delai = "$jours " . _T("date_jours"); |
|
| 403 | + } |
|
| 404 | + } else { |
|
| 405 | + if ($decal >= 3600) { |
|
| 406 | + $heures = floor($decal / 3600); |
|
| 407 | + if ($heures < 2) { |
|
| 408 | + $delai = "$heures " . _T("date_une_heure"); |
|
| 409 | + } else { |
|
| 410 | + $delai = "$heures " . _T("date_heures"); |
|
| 411 | + } |
|
| 412 | + } else { |
|
| 413 | + if ($decal >= 60) { |
|
| 414 | + $minutes = floor($decal / 60); |
|
| 415 | + if ($minutes < 2) { |
|
| 416 | + $delai = "$minutes " . _T("date_une_minute"); |
|
| 417 | + } else { |
|
| 418 | + $delai = "$minutes " . _T("date_minutes"); |
|
| 419 | + } |
|
| 420 | + } else { |
|
| 421 | + $secondes = ceil($decal); |
|
| 422 | + if ($secondes < 2) { |
|
| 423 | + $delai = "$secondes " . _T("date_une_seconde"); |
|
| 424 | + } else { |
|
| 425 | + $delai = "$secondes " . _T("date_secondes"); |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + return _T($il_y_a, array("delai" => $delai)); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | |
@@ -456,32 +456,32 @@ discard block |
||
| 456 | 456 | **/ |
| 457 | 457 | function date_relativecourt($date, $decalage_maxi = 0) { |
| 458 | 458 | |
| 459 | - if (!$date) { |
|
| 460 | - return; |
|
| 461 | - } |
|
| 462 | - $decal = date("U", strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 463 | - |
|
| 464 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 465 | - return ''; |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - if ($decal < -24 * 3600) { |
|
| 469 | - $retour = date_relative($date, $decalage_maxi); |
|
| 470 | - } elseif ($decal < 0) { |
|
| 471 | - $retour = _T("date_demain"); |
|
| 472 | - } else { |
|
| 473 | - if ($decal < (3600 * 24)) { |
|
| 474 | - $retour = _T("date_aujourdhui"); |
|
| 475 | - } else { |
|
| 476 | - if ($decal < (3600 * 24 * 2)) { |
|
| 477 | - $retour = _T("date_hier"); |
|
| 478 | - } else { |
|
| 479 | - $retour = date_relative($date, $decalage_maxi); |
|
| 480 | - } |
|
| 481 | - } |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - return $retour; |
|
| 459 | + if (!$date) { |
|
| 460 | + return; |
|
| 461 | + } |
|
| 462 | + $decal = date("U", strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 463 | + |
|
| 464 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 465 | + return ''; |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + if ($decal < -24 * 3600) { |
|
| 469 | + $retour = date_relative($date, $decalage_maxi); |
|
| 470 | + } elseif ($decal < 0) { |
|
| 471 | + $retour = _T("date_demain"); |
|
| 472 | + } else { |
|
| 473 | + if ($decal < (3600 * 24)) { |
|
| 474 | + $retour = _T("date_aujourdhui"); |
|
| 475 | + } else { |
|
| 476 | + if ($decal < (3600 * 24 * 2)) { |
|
| 477 | + $retour = _T("date_hier"); |
|
| 478 | + } else { |
|
| 479 | + $retour = date_relative($date, $decalage_maxi); |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + return $retour; |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -500,162 +500,162 @@ discard block |
||
| 500 | 500 | * @return mixed|string |
| 501 | 501 | */ |
| 502 | 502 | function affdate_base($numdate, $vue, $options = array()) { |
| 503 | - if (is_string($options)) { |
|
| 504 | - $options = array('param' => $options); |
|
| 505 | - } |
|
| 506 | - $date_array = recup_date($numdate, false); |
|
| 507 | - if (!$date_array) { |
|
| 508 | - return; |
|
| 509 | - } |
|
| 510 | - list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 511 | - |
|
| 512 | - // 1er, 21st, etc. |
|
| 513 | - $journum = $jour; |
|
| 514 | - |
|
| 515 | - if ($jour == 0) { |
|
| 516 | - $jour = ''; |
|
| 517 | - $njour = 0; |
|
| 518 | - } else { |
|
| 519 | - $njour = intval($jour); |
|
| 520 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 521 | - $jour = $jourth; |
|
| 522 | - } |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - $mois = intval($mois); |
|
| 526 | - if ($mois > 0 and $mois < 13) { |
|
| 527 | - /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 528 | - $param = ((isset($options['param']) and $options['param'] === "abbr") ? '_' . $options['param'] : ''); |
|
| 529 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 530 | - if ($jour) { |
|
| 531 | - $jourmois = _T('date_de_mois_' . $mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 532 | - } else { |
|
| 533 | - $jourmois = $nommois; |
|
| 534 | - } |
|
| 535 | - } else { |
|
| 536 | - $nommois = ''; |
|
| 537 | - $jourmois = ''; |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - if ($annee < 0) { |
|
| 541 | - $annee = -$annee . " " . _T('date_avant_jc'); |
|
| 542 | - $avjc = true; |
|
| 543 | - } else { |
|
| 544 | - $avjc = false; |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - switch ($vue) { |
|
| 548 | - case 'saison': |
|
| 549 | - case 'saison_annee': |
|
| 550 | - $saison = ''; |
|
| 551 | - if ($mois > 0) { |
|
| 552 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 553 | - if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 554 | - $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 555 | - } |
|
| 556 | - if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 557 | - $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 558 | - } |
|
| 559 | - if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 560 | - $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 561 | - } |
|
| 562 | - if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 563 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - if ($vue == 'saison') { |
|
| 567 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 568 | - } else { |
|
| 569 | - return $saison ? trim(_T('date_fmt_saison_annee', |
|
| 570 | - array('saison' => _T('date_saison_' . $saison), 'annee' => $annee))) : ''; |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - case 'court': |
|
| 574 | - if ($avjc) { |
|
| 575 | - return $annee; |
|
| 576 | - } |
|
| 577 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 578 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 579 | - return $annee; |
|
| 580 | - } |
|
| 581 | - if ($annee != $a) { |
|
| 582 | - return _T('date_fmt_mois_annee', |
|
| 583 | - array('mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee)); |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - return _T('date_fmt_jour_mois', |
|
| 587 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 588 | - |
|
| 589 | - case 'jourcourt': |
|
| 590 | - if ($avjc) { |
|
| 591 | - return $annee; |
|
| 592 | - } |
|
| 593 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 594 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 595 | - return $annee; |
|
| 596 | - } |
|
| 597 | - if ($annee != $a) { |
|
| 598 | - return _T('date_fmt_jour_mois_annee', |
|
| 599 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - return _T('date_fmt_jour_mois', |
|
| 603 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 604 | - |
|
| 605 | - case 'entier': |
|
| 606 | - if ($avjc) { |
|
| 607 | - return $annee; |
|
| 608 | - } |
|
| 609 | - if ($jour) { |
|
| 610 | - return _T('date_fmt_jour_mois_annee', |
|
| 611 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 612 | - } elseif ($mois) { |
|
| 613 | - return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 614 | - } else { |
|
| 615 | - return $annee; |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - case 'nom_mois': |
|
| 619 | - return $nommois; |
|
| 620 | - |
|
| 621 | - case 'mois': |
|
| 622 | - return sprintf("%02s", $mois); |
|
| 623 | - |
|
| 624 | - case 'jour': |
|
| 625 | - return $jour; |
|
| 626 | - |
|
| 627 | - case 'journum': |
|
| 628 | - return $journum; |
|
| 629 | - |
|
| 630 | - case 'nom_jour': |
|
| 631 | - if (!$mois or !$njour) { |
|
| 632 | - return ''; |
|
| 633 | - } |
|
| 634 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 635 | - $nom = 1 + date('w', $nom); |
|
| 636 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 637 | - |
|
| 638 | - return _T('date_jour_' . $nom . $param); |
|
| 639 | - |
|
| 640 | - case 'mois_annee': |
|
| 641 | - if ($avjc) { |
|
| 642 | - return $annee; |
|
| 643 | - } |
|
| 644 | - |
|
| 645 | - return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 646 | - |
|
| 647 | - case 'annee': |
|
| 648 | - return $annee; |
|
| 649 | - |
|
| 650 | - // Cas d'une vue non definie : retomber sur le format |
|
| 651 | - // de date propose par http://www.php.net/date |
|
| 652 | - default: |
|
| 653 | - list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 654 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee)) { |
|
| 655 | - $time = strtotime($numdate); |
|
| 656 | - } |
|
| 657 | - return date($vue, $time); |
|
| 658 | - } |
|
| 503 | + if (is_string($options)) { |
|
| 504 | + $options = array('param' => $options); |
|
| 505 | + } |
|
| 506 | + $date_array = recup_date($numdate, false); |
|
| 507 | + if (!$date_array) { |
|
| 508 | + return; |
|
| 509 | + } |
|
| 510 | + list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 511 | + |
|
| 512 | + // 1er, 21st, etc. |
|
| 513 | + $journum = $jour; |
|
| 514 | + |
|
| 515 | + if ($jour == 0) { |
|
| 516 | + $jour = ''; |
|
| 517 | + $njour = 0; |
|
| 518 | + } else { |
|
| 519 | + $njour = intval($jour); |
|
| 520 | + if ($jourth = _T('date_jnum' . $jour)) { |
|
| 521 | + $jour = $jourth; |
|
| 522 | + } |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + $mois = intval($mois); |
|
| 526 | + if ($mois > 0 and $mois < 13) { |
|
| 527 | + /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 528 | + $param = ((isset($options['param']) and $options['param'] === "abbr") ? '_' . $options['param'] : ''); |
|
| 529 | + $nommois = _T('date_mois_' . $mois . $param); |
|
| 530 | + if ($jour) { |
|
| 531 | + $jourmois = _T('date_de_mois_' . $mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 532 | + } else { |
|
| 533 | + $jourmois = $nommois; |
|
| 534 | + } |
|
| 535 | + } else { |
|
| 536 | + $nommois = ''; |
|
| 537 | + $jourmois = ''; |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + if ($annee < 0) { |
|
| 541 | + $annee = -$annee . " " . _T('date_avant_jc'); |
|
| 542 | + $avjc = true; |
|
| 543 | + } else { |
|
| 544 | + $avjc = false; |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + switch ($vue) { |
|
| 548 | + case 'saison': |
|
| 549 | + case 'saison_annee': |
|
| 550 | + $saison = ''; |
|
| 551 | + if ($mois > 0) { |
|
| 552 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 553 | + if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 554 | + $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 555 | + } |
|
| 556 | + if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 557 | + $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 558 | + } |
|
| 559 | + if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 560 | + $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 561 | + } |
|
| 562 | + if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 563 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + if ($vue == 'saison') { |
|
| 567 | + return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 568 | + } else { |
|
| 569 | + return $saison ? trim(_T('date_fmt_saison_annee', |
|
| 570 | + array('saison' => _T('date_saison_' . $saison), 'annee' => $annee))) : ''; |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + case 'court': |
|
| 574 | + if ($avjc) { |
|
| 575 | + return $annee; |
|
| 576 | + } |
|
| 577 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 578 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 579 | + return $annee; |
|
| 580 | + } |
|
| 581 | + if ($annee != $a) { |
|
| 582 | + return _T('date_fmt_mois_annee', |
|
| 583 | + array('mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee)); |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + return _T('date_fmt_jour_mois', |
|
| 587 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 588 | + |
|
| 589 | + case 'jourcourt': |
|
| 590 | + if ($avjc) { |
|
| 591 | + return $annee; |
|
| 592 | + } |
|
| 593 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 594 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 595 | + return $annee; |
|
| 596 | + } |
|
| 597 | + if ($annee != $a) { |
|
| 598 | + return _T('date_fmt_jour_mois_annee', |
|
| 599 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + return _T('date_fmt_jour_mois', |
|
| 603 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 604 | + |
|
| 605 | + case 'entier': |
|
| 606 | + if ($avjc) { |
|
| 607 | + return $annee; |
|
| 608 | + } |
|
| 609 | + if ($jour) { |
|
| 610 | + return _T('date_fmt_jour_mois_annee', |
|
| 611 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 612 | + } elseif ($mois) { |
|
| 613 | + return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 614 | + } else { |
|
| 615 | + return $annee; |
|
| 616 | + } |
|
| 617 | + |
|
| 618 | + case 'nom_mois': |
|
| 619 | + return $nommois; |
|
| 620 | + |
|
| 621 | + case 'mois': |
|
| 622 | + return sprintf("%02s", $mois); |
|
| 623 | + |
|
| 624 | + case 'jour': |
|
| 625 | + return $jour; |
|
| 626 | + |
|
| 627 | + case 'journum': |
|
| 628 | + return $journum; |
|
| 629 | + |
|
| 630 | + case 'nom_jour': |
|
| 631 | + if (!$mois or !$njour) { |
|
| 632 | + return ''; |
|
| 633 | + } |
|
| 634 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 635 | + $nom = 1 + date('w', $nom); |
|
| 636 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 637 | + |
|
| 638 | + return _T('date_jour_' . $nom . $param); |
|
| 639 | + |
|
| 640 | + case 'mois_annee': |
|
| 641 | + if ($avjc) { |
|
| 642 | + return $annee; |
|
| 643 | + } |
|
| 644 | + |
|
| 645 | + return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 646 | + |
|
| 647 | + case 'annee': |
|
| 648 | + return $annee; |
|
| 649 | + |
|
| 650 | + // Cas d'une vue non definie : retomber sur le format |
|
| 651 | + // de date propose par http://www.php.net/date |
|
| 652 | + default: |
|
| 653 | + list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 654 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee)) { |
|
| 655 | + $time = strtotime($numdate); |
|
| 656 | + } |
|
| 657 | + return date($vue, $time); |
|
| 658 | + } |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | |
@@ -682,11 +682,11 @@ discard block |
||
| 682 | 682 | * Nom du jour |
| 683 | 683 | **/ |
| 684 | 684 | function nom_jour($numdate, $forme = '') { |
| 685 | - if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 686 | - $forme = ''; |
|
| 687 | - } |
|
| 685 | + if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 686 | + $forme = ''; |
|
| 687 | + } |
|
| 688 | 688 | |
| 689 | - return affdate_base($numdate, 'nom_jour', $forme); |
|
| 689 | + return affdate_base($numdate, 'nom_jour', $forme); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /** |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | * Numéro du jour |
| 709 | 709 | **/ |
| 710 | 710 | function jour($numdate) { |
| 711 | - return affdate_base($numdate, 'jour'); |
|
| 711 | + return affdate_base($numdate, 'jour'); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | /** |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | * Numéro du jour |
| 727 | 727 | **/ |
| 728 | 728 | function journum($numdate) { |
| 729 | - return affdate_base($numdate, 'journum'); |
|
| 729 | + return affdate_base($numdate, 'journum'); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | /** |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | * Numéro du mois (sur 2 chiffres) |
| 745 | 745 | **/ |
| 746 | 746 | function mois($numdate) { |
| 747 | - return affdate_base($numdate, 'mois'); |
|
| 747 | + return affdate_base($numdate, 'mois'); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | /** |
@@ -768,11 +768,11 @@ discard block |
||
| 768 | 768 | * Nom du mois |
| 769 | 769 | **/ |
| 770 | 770 | function nom_mois($numdate, $forme = '') { |
| 771 | - if (!($forme == 'abbr')) { |
|
| 772 | - $forme = ''; |
|
| 773 | - } |
|
| 771 | + if (!($forme == 'abbr')) { |
|
| 772 | + $forme = ''; |
|
| 773 | + } |
|
| 774 | 774 | |
| 775 | - return affdate_base($numdate, 'nom_mois', $forme); |
|
| 775 | + return affdate_base($numdate, 'nom_mois', $forme); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | /** |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | * Année (sur 4 chiffres) |
| 791 | 791 | **/ |
| 792 | 792 | function annee($numdate) { |
| 793 | - return affdate_base($numdate, 'annee'); |
|
| 793 | + return affdate_base($numdate, 'annee'); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | |
@@ -820,11 +820,11 @@ discard block |
||
| 820 | 820 | * La date formatée |
| 821 | 821 | **/ |
| 822 | 822 | function saison($numdate, $hemisphere = 'nord') { |
| 823 | - if ($hemisphere != 'sud') { |
|
| 824 | - $hemisphere = 'nord'; |
|
| 825 | - } |
|
| 823 | + if ($hemisphere != 'sud') { |
|
| 824 | + $hemisphere = 'nord'; |
|
| 825 | + } |
|
| 826 | 826 | |
| 827 | - return affdate_base($numdate, 'saison', $hemisphere); |
|
| 827 | + return affdate_base($numdate, 'saison', $hemisphere); |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | |
@@ -853,11 +853,11 @@ discard block |
||
| 853 | 853 | * La date formatée |
| 854 | 854 | **/ |
| 855 | 855 | function saison_annee($numdate, $hemisphere = 'nord') { |
| 856 | - if ($hemisphere != 'sud') { |
|
| 857 | - $hemisphere = 'nord'; |
|
| 858 | - } |
|
| 856 | + if ($hemisphere != 'sud') { |
|
| 857 | + $hemisphere = 'nord'; |
|
| 858 | + } |
|
| 859 | 859 | |
| 860 | - return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 860 | + return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | /** |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | * La date formatée |
| 886 | 886 | **/ |
| 887 | 887 | function affdate($numdate, $format = 'entier') { |
| 888 | - return affdate_base($numdate, $format); |
|
| 888 | + return affdate_base($numdate, $format); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | * La date formatée |
| 913 | 913 | **/ |
| 914 | 914 | function affdate_court($numdate, $annee_courante = null) { |
| 915 | - return affdate_base($numdate, 'court', array('annee_courante' => $annee_courante)); |
|
| 915 | + return affdate_base($numdate, 'court', array('annee_courante' => $annee_courante)); |
|
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | |
@@ -939,7 +939,7 @@ discard block |
||
| 939 | 939 | * La date formatée |
| 940 | 940 | **/ |
| 941 | 941 | function affdate_jourcourt($numdate, $annee_courante = null) { |
| 942 | - return affdate_base($numdate, 'jourcourt', array('annee_courante' => $annee_courante)); |
|
| 942 | + return affdate_base($numdate, 'jourcourt', array('annee_courante' => $annee_courante)); |
|
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | /** |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | * La date formatée |
| 958 | 958 | **/ |
| 959 | 959 | function affdate_mois_annee($numdate) { |
| 960 | - return affdate_base($numdate, 'mois_annee'); |
|
| 960 | + return affdate_base($numdate, 'mois_annee'); |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | /** |
@@ -975,16 +975,16 @@ discard block |
||
| 975 | 975 | * La date formatée |
| 976 | 976 | **/ |
| 977 | 977 | function affdate_heure($numdate) { |
| 978 | - $date_array = recup_date($numdate); |
|
| 979 | - if (!$date_array) { |
|
| 980 | - return; |
|
| 981 | - } |
|
| 982 | - list($annee, $mois, $jour, $heures, $minutes, $sec) = $date_array; |
|
| 983 | - |
|
| 984 | - return _T('date_fmt_jour_heure', array( |
|
| 985 | - 'jour' => affdate($numdate), |
|
| 986 | - 'heure' => _T('date_fmt_heures_minutes', array('h' => $heures, 'm' => $minutes)) |
|
| 987 | - )); |
|
| 978 | + $date_array = recup_date($numdate); |
|
| 979 | + if (!$date_array) { |
|
| 980 | + return; |
|
| 981 | + } |
|
| 982 | + list($annee, $mois, $jour, $heures, $minutes, $sec) = $date_array; |
|
| 983 | + |
|
| 984 | + return _T('date_fmt_jour_heure', array( |
|
| 985 | + 'jour' => affdate($numdate), |
|
| 986 | + 'heure' => _T('date_fmt_heures_minutes', array('h' => $heures, 'm' => $minutes)) |
|
| 987 | + )); |
|
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | /** |
@@ -1016,114 +1016,114 @@ discard block |
||
| 1016 | 1016 | * Texte de la date |
| 1017 | 1017 | */ |
| 1018 | 1018 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = '') { |
| 1019 | - $abbr = $jour = ''; |
|
| 1020 | - $affdate = "affdate_jourcourt"; |
|
| 1021 | - if (strpos($forme, 'abbr') !== false) { |
|
| 1022 | - $abbr = 'abbr'; |
|
| 1023 | - } |
|
| 1024 | - if (strpos($forme, 'annee') !== false) { |
|
| 1025 | - $affdate = 'affdate'; |
|
| 1026 | - } |
|
| 1027 | - if (strpos($forme, 'jour') !== false) { |
|
| 1028 | - $jour = 'jour'; |
|
| 1029 | - } |
|
| 1030 | - |
|
| 1031 | - $dtstart = $dtend = $dtabbr = ""; |
|
| 1032 | - if (strpos($forme, 'hcal') !== false) { |
|
| 1033 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1034 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1035 | - $dtabbr = "</abbr>"; |
|
| 1036 | - } |
|
| 1037 | - |
|
| 1038 | - $date_debut = strtotime($date_debut); |
|
| 1039 | - $date_fin = strtotime($date_fin); |
|
| 1040 | - $d = date("Y-m-d", $date_debut); |
|
| 1041 | - $f = date("Y-m-d", $date_fin); |
|
| 1042 | - $h = ($horaire === 'oui' or $horaire === true); |
|
| 1043 | - $hd = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_debut), 'm' => date("i", $date_debut))); |
|
| 1044 | - $hf = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_fin), 'm' => date("i", $date_fin))); |
|
| 1045 | - |
|
| 1046 | - if ($d == $f) { // meme jour |
|
| 1047 | - $nomjour = nom_jour($d, $abbr); |
|
| 1048 | - $s = $affdate($d); |
|
| 1049 | - $s = _T('date_fmt_jour', array('nomjour' => $nomjour, 'jour' => $s)); |
|
| 1050 | - if ($h) { |
|
| 1051 | - if ($hd == $hf) { |
|
| 1052 | - // Lundi 20 fevrier a 18h25 |
|
| 1053 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', array('jour' => $s, 'heure' => $hd))); |
|
| 1054 | - $s = "$dtstart$s$dtabbr"; |
|
| 1055 | - } else { |
|
| 1056 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1057 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1058 | - $s = _T('date_fmt_jour_heure_debut_fin_abbr', array( |
|
| 1059 | - 'jour' => spip_ucfirst($s), |
|
| 1060 | - 'heure_debut' => $hd, |
|
| 1061 | - 'heure_fin' => $hf, |
|
| 1062 | - 'dtstart' => $dtstart, |
|
| 1063 | - 'dtend' => $dtend, |
|
| 1064 | - 'dtabbr' => $dtabbr |
|
| 1065 | - ), |
|
| 1066 | - array( |
|
| 1067 | - 'sanitize' => false |
|
| 1068 | - ) |
|
| 1069 | - ); |
|
| 1070 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1071 | - else { |
|
| 1072 | - $s = spip_ucfirst(_T('date_fmt_jour_heure_debut_fin', |
|
| 1073 | - array('jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf))); |
|
| 1074 | - } |
|
| 1075 | - } |
|
| 1076 | - } else { |
|
| 1077 | - if ($dtabbr && $dtstart) { |
|
| 1078 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1079 | - } else { |
|
| 1080 | - $s = spip_ucfirst($s); |
|
| 1081 | - } |
|
| 1082 | - } |
|
| 1083 | - } else { |
|
| 1084 | - if ((date("Y-m", $date_debut)) == date("Y-m", $date_fin)) { // meme annee et mois, jours differents |
|
| 1085 | - if (!$h) { |
|
| 1086 | - $date_debut = jour($d); |
|
| 1087 | - } else { |
|
| 1088 | - $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1089 | - } |
|
| 1090 | - $date_fin = $affdate($f); |
|
| 1091 | - if ($jour) { |
|
| 1092 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1093 | - $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1094 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1095 | - $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1096 | - } |
|
| 1097 | - if ($h) { |
|
| 1098 | - $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1099 | - $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1100 | - } |
|
| 1101 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1102 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1103 | - |
|
| 1104 | - $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1105 | - } else { |
|
| 1106 | - $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1107 | - $date_fin = $affdate($f); |
|
| 1108 | - if ($jour) { |
|
| 1109 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1110 | - $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1111 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1112 | - $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1113 | - } |
|
| 1114 | - if ($h) { |
|
| 1115 | - $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1116 | - $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1117 | - } |
|
| 1118 | - |
|
| 1119 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1120 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1121 | - $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1122 | - |
|
| 1123 | - } |
|
| 1124 | - } |
|
| 1125 | - |
|
| 1126 | - return $s; |
|
| 1019 | + $abbr = $jour = ''; |
|
| 1020 | + $affdate = "affdate_jourcourt"; |
|
| 1021 | + if (strpos($forme, 'abbr') !== false) { |
|
| 1022 | + $abbr = 'abbr'; |
|
| 1023 | + } |
|
| 1024 | + if (strpos($forme, 'annee') !== false) { |
|
| 1025 | + $affdate = 'affdate'; |
|
| 1026 | + } |
|
| 1027 | + if (strpos($forme, 'jour') !== false) { |
|
| 1028 | + $jour = 'jour'; |
|
| 1029 | + } |
|
| 1030 | + |
|
| 1031 | + $dtstart = $dtend = $dtabbr = ""; |
|
| 1032 | + if (strpos($forme, 'hcal') !== false) { |
|
| 1033 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1034 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1035 | + $dtabbr = "</abbr>"; |
|
| 1036 | + } |
|
| 1037 | + |
|
| 1038 | + $date_debut = strtotime($date_debut); |
|
| 1039 | + $date_fin = strtotime($date_fin); |
|
| 1040 | + $d = date("Y-m-d", $date_debut); |
|
| 1041 | + $f = date("Y-m-d", $date_fin); |
|
| 1042 | + $h = ($horaire === 'oui' or $horaire === true); |
|
| 1043 | + $hd = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_debut), 'm' => date("i", $date_debut))); |
|
| 1044 | + $hf = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_fin), 'm' => date("i", $date_fin))); |
|
| 1045 | + |
|
| 1046 | + if ($d == $f) { // meme jour |
|
| 1047 | + $nomjour = nom_jour($d, $abbr); |
|
| 1048 | + $s = $affdate($d); |
|
| 1049 | + $s = _T('date_fmt_jour', array('nomjour' => $nomjour, 'jour' => $s)); |
|
| 1050 | + if ($h) { |
|
| 1051 | + if ($hd == $hf) { |
|
| 1052 | + // Lundi 20 fevrier a 18h25 |
|
| 1053 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', array('jour' => $s, 'heure' => $hd))); |
|
| 1054 | + $s = "$dtstart$s$dtabbr"; |
|
| 1055 | + } else { |
|
| 1056 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1057 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1058 | + $s = _T('date_fmt_jour_heure_debut_fin_abbr', array( |
|
| 1059 | + 'jour' => spip_ucfirst($s), |
|
| 1060 | + 'heure_debut' => $hd, |
|
| 1061 | + 'heure_fin' => $hf, |
|
| 1062 | + 'dtstart' => $dtstart, |
|
| 1063 | + 'dtend' => $dtend, |
|
| 1064 | + 'dtabbr' => $dtabbr |
|
| 1065 | + ), |
|
| 1066 | + array( |
|
| 1067 | + 'sanitize' => false |
|
| 1068 | + ) |
|
| 1069 | + ); |
|
| 1070 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1071 | + else { |
|
| 1072 | + $s = spip_ucfirst(_T('date_fmt_jour_heure_debut_fin', |
|
| 1073 | + array('jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf))); |
|
| 1074 | + } |
|
| 1075 | + } |
|
| 1076 | + } else { |
|
| 1077 | + if ($dtabbr && $dtstart) { |
|
| 1078 | + $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1079 | + } else { |
|
| 1080 | + $s = spip_ucfirst($s); |
|
| 1081 | + } |
|
| 1082 | + } |
|
| 1083 | + } else { |
|
| 1084 | + if ((date("Y-m", $date_debut)) == date("Y-m", $date_fin)) { // meme annee et mois, jours differents |
|
| 1085 | + if (!$h) { |
|
| 1086 | + $date_debut = jour($d); |
|
| 1087 | + } else { |
|
| 1088 | + $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1089 | + } |
|
| 1090 | + $date_fin = $affdate($f); |
|
| 1091 | + if ($jour) { |
|
| 1092 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1093 | + $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1094 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1095 | + $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1096 | + } |
|
| 1097 | + if ($h) { |
|
| 1098 | + $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1099 | + $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1100 | + } |
|
| 1101 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1102 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1103 | + |
|
| 1104 | + $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1105 | + } else { |
|
| 1106 | + $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1107 | + $date_fin = $affdate($f); |
|
| 1108 | + if ($jour) { |
|
| 1109 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1110 | + $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1111 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1112 | + $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1113 | + } |
|
| 1114 | + if ($h) { |
|
| 1115 | + $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1116 | + $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1117 | + } |
|
| 1118 | + |
|
| 1119 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1120 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1121 | + $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1122 | + |
|
| 1123 | + } |
|
| 1124 | + } |
|
| 1125 | + |
|
| 1126 | + return $s; |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | /** |
@@ -1144,10 +1144,10 @@ discard block |
||
| 1144 | 1144 | * Date au format ical |
| 1145 | 1145 | **/ |
| 1146 | 1146 | function date_ical($date, $addminutes = 0) { |
| 1147 | - list($heures, $minutes, $secondes) = recup_heure($date); |
|
| 1148 | - list($annee, $mois, $jour) = recup_date($date); |
|
| 1147 | + list($heures, $minutes, $secondes) = recup_heure($date); |
|
| 1148 | + list($annee, $mois, $jour) = recup_date($date); |
|
| 1149 | 1149 | |
| 1150 | - return gmdate("Ymd\THis\Z", mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1150 | + return gmdate("Ymd\THis\Z", mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | |
@@ -1171,11 +1171,11 @@ discard block |
||
| 1171 | 1171 | * La date formatée |
| 1172 | 1172 | **/ |
| 1173 | 1173 | function date_iso($date_heure) { |
| 1174 | - list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1175 | - list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1176 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1174 | + list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1175 | + list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1176 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1177 | 1177 | |
| 1178 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1178 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | 1181 | /** |
@@ -1198,11 +1198,11 @@ discard block |
||
| 1198 | 1198 | * La date formatée |
| 1199 | 1199 | **/ |
| 1200 | 1200 | function date_822($date_heure) { |
| 1201 | - list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1202 | - list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1203 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1201 | + list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1202 | + list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1203 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1204 | 1204 | |
| 1205 | - return date('r', $time); |
|
| 1205 | + return date('r', $time); |
|
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | 1208 | /** |
@@ -1218,11 +1218,11 @@ discard block |
||
| 1218 | 1218 | * Date au format `Ymd` |
| 1219 | 1219 | **/ |
| 1220 | 1220 | function date_anneemoisjour($d) { |
| 1221 | - if (!$d) { |
|
| 1222 | - $d = date("Y-m-d"); |
|
| 1223 | - } |
|
| 1221 | + if (!$d) { |
|
| 1222 | + $d = date("Y-m-d"); |
|
| 1223 | + } |
|
| 1224 | 1224 | |
| 1225 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1225 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | /** |
@@ -1238,11 +1238,11 @@ discard block |
||
| 1238 | 1238 | * Date au format `Ym` |
| 1239 | 1239 | **/ |
| 1240 | 1240 | function date_anneemois($d) { |
| 1241 | - if (!$d) { |
|
| 1242 | - $d = date("Y-m-d"); |
|
| 1243 | - } |
|
| 1241 | + if (!$d) { |
|
| 1242 | + $d = date("Y-m-d"); |
|
| 1243 | + } |
|
| 1244 | 1244 | |
| 1245 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1245 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | /** |
@@ -1258,13 +1258,13 @@ discard block |
||
| 1258 | 1258 | * Date au lundi de la même semaine au format `Ymd` |
| 1259 | 1259 | **/ |
| 1260 | 1260 | function date_debut_semaine($annee, $mois, $jour) { |
| 1261 | - $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1262 | - if ($w_day == 0) { |
|
| 1263 | - $w_day = 7; |
|
| 1264 | - } // Gaffe: le dimanche est zero |
|
| 1265 | - $debut = $jour - $w_day + 1; |
|
| 1261 | + $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1262 | + if ($w_day == 0) { |
|
| 1263 | + $w_day = 7; |
|
| 1264 | + } // Gaffe: le dimanche est zero |
|
| 1265 | + $debut = $jour - $w_day + 1; |
|
| 1266 | 1266 | |
| 1267 | - return date("Ymd", mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1267 | + return date("Ymd", mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | 1270 | /** |
@@ -1280,12 +1280,12 @@ discard block |
||
| 1280 | 1280 | * Date au dimanche de la même semaine au format `Ymd` |
| 1281 | 1281 | **/ |
| 1282 | 1282 | function date_fin_semaine($annee, $mois, $jour) { |
| 1283 | - $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1284 | - if ($w_day == 0) { |
|
| 1285 | - $w_day = 7; |
|
| 1286 | - } // Gaffe: le dimanche est zero |
|
| 1287 | - $debut = $jour - $w_day + 1; |
|
| 1283 | + $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1284 | + if ($w_day == 0) { |
|
| 1285 | + $w_day = 7; |
|
| 1286 | + } // Gaffe: le dimanche est zero |
|
| 1287 | + $debut = $jour - $w_day + 1; |
|
| 1288 | 1288 | |
| 1289 | - return date("Ymd", mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1289 | + return date("Ymd", mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | function extraire_date($texte) { |
| 39 | 39 | // format = 2001-08 |
| 40 | 40 | if (preg_match(",([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),", $texte, $regs)) { |
| 41 | - return $regs[1] . "-" . sprintf("%02d", $regs[2]) . "-01"; |
|
| 41 | + return $regs[1]."-".sprintf("%02d", $regs[2])."-01"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | if (preg_match("#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
| 70 | 70 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 71 | - $date = $regs[1] . "-00-00" . $regs[3]; |
|
| 71 | + $date = $regs[1]."-00-00".$regs[3]; |
|
| 72 | 72 | } else { |
| 73 | 73 | if (preg_match("#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
| 74 | 74 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 75 | - $date = preg_replace("@/@", "-", $regs[1]) . "-00" . $regs[3]; |
|
| 75 | + $date = preg_replace("@/@", "-", $regs[1])."-00".$regs[3]; |
|
| 76 | 76 | } else { |
| 77 | 77 | $date = date("Y-m-d H:i:s", strtotime($date)); |
| 78 | 78 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | **/ |
| 98 | 98 | function vider_date($letexte, $verif_format_date = false) { |
| 99 | 99 | if (!$verif_format_date |
| 100 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 100 | + or (in_array(strlen($letexte), [10, 19]) and |
|
| 101 | 101 | preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/", $letexte))) { |
| 102 | 102 | |
| 103 | 103 | if (strncmp("0000-00-00", $letexte, 10) == 0) { |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | * - si 'abbr' ne précise pas l'unité des minutes : 12h10 |
| 209 | 209 | * @return string L'heure formatée dans la langue en cours. |
| 210 | 210 | **/ |
| 211 | -function heures_minutes($numdate, $forme='') { |
|
| 212 | - if ($forme !='abbr') { |
|
| 211 | +function heures_minutes($numdate, $forme = '') { |
|
| 212 | + if ($forme != 'abbr') { |
|
| 213 | 213 | return _T('date_fmt_heures_minutes', array('h' => heures($numdate), 'm' => minutes($numdate))); |
| 214 | 214 | } |
| 215 | 215 | else { |
@@ -381,17 +381,17 @@ discard block |
||
| 381 | 381 | if ($decal > 3600 * 24 * 30) { |
| 382 | 382 | $mois = floor($decal / (3600 * 24 * 30)); |
| 383 | 383 | if ($mois < 2) { |
| 384 | - $delai = "$mois " . _T("date_un_mois"); |
|
| 384 | + $delai = "$mois "._T("date_un_mois"); |
|
| 385 | 385 | } else { |
| 386 | - $delai = "$mois " . _T("date_mois"); |
|
| 386 | + $delai = "$mois "._T("date_mois"); |
|
| 387 | 387 | } |
| 388 | 388 | } else { |
| 389 | 389 | if ($decal > 3600 * 24 * 7) { |
| 390 | 390 | $semaines = floor($decal / (3600 * 24 * 7)); |
| 391 | 391 | if ($semaines < 2) { |
| 392 | - $delai = "$semaines " . _T("date_une_semaine"); |
|
| 392 | + $delai = "$semaines "._T("date_une_semaine"); |
|
| 393 | 393 | } else { |
| 394 | - $delai = "$semaines " . _T("date_semaines"); |
|
| 394 | + $delai = "$semaines "._T("date_semaines"); |
|
| 395 | 395 | } |
| 396 | 396 | } else { |
| 397 | 397 | if ($decal > 3600 * 24) { |
@@ -399,30 +399,30 @@ discard block |
||
| 399 | 399 | if ($jours < 2) { |
| 400 | 400 | return $il_y_a == "date_dans" ? _T("date_demain") : _T("date_hier"); |
| 401 | 401 | } else { |
| 402 | - $delai = "$jours " . _T("date_jours"); |
|
| 402 | + $delai = "$jours "._T("date_jours"); |
|
| 403 | 403 | } |
| 404 | 404 | } else { |
| 405 | 405 | if ($decal >= 3600) { |
| 406 | 406 | $heures = floor($decal / 3600); |
| 407 | 407 | if ($heures < 2) { |
| 408 | - $delai = "$heures " . _T("date_une_heure"); |
|
| 408 | + $delai = "$heures "._T("date_une_heure"); |
|
| 409 | 409 | } else { |
| 410 | - $delai = "$heures " . _T("date_heures"); |
|
| 410 | + $delai = "$heures "._T("date_heures"); |
|
| 411 | 411 | } |
| 412 | 412 | } else { |
| 413 | 413 | if ($decal >= 60) { |
| 414 | 414 | $minutes = floor($decal / 60); |
| 415 | 415 | if ($minutes < 2) { |
| 416 | - $delai = "$minutes " . _T("date_une_minute"); |
|
| 416 | + $delai = "$minutes "._T("date_une_minute"); |
|
| 417 | 417 | } else { |
| 418 | - $delai = "$minutes " . _T("date_minutes"); |
|
| 418 | + $delai = "$minutes "._T("date_minutes"); |
|
| 419 | 419 | } |
| 420 | 420 | } else { |
| 421 | 421 | $secondes = ceil($decal); |
| 422 | 422 | if ($secondes < 2) { |
| 423 | - $delai = "$secondes " . _T("date_une_seconde"); |
|
| 423 | + $delai = "$secondes "._T("date_une_seconde"); |
|
| 424 | 424 | } else { |
| 425 | - $delai = "$secondes " . _T("date_secondes"); |
|
| 425 | + $delai = "$secondes "._T("date_secondes"); |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | $njour = 0; |
| 518 | 518 | } else { |
| 519 | 519 | $njour = intval($jour); |
| 520 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 520 | + if ($jourth = _T('date_jnum'.$jour)) { |
|
| 521 | 521 | $jour = $jourth; |
| 522 | 522 | } |
| 523 | 523 | } |
@@ -525,10 +525,10 @@ discard block |
||
| 525 | 525 | $mois = intval($mois); |
| 526 | 526 | if ($mois > 0 and $mois < 13) { |
| 527 | 527 | /* Traiter le cas "abbr" pour les noms de mois */ |
| 528 | - $param = ((isset($options['param']) and $options['param'] === "abbr") ? '_' . $options['param'] : ''); |
|
| 529 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 528 | + $param = ((isset($options['param']) and $options['param'] === "abbr") ? '_'.$options['param'] : ''); |
|
| 529 | + $nommois = _T('date_mois_'.$mois.$param); |
|
| 530 | 530 | if ($jour) { |
| 531 | - $jourmois = _T('date_de_mois_' . $mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 531 | + $jourmois = _T('date_de_mois_'.$mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 532 | 532 | } else { |
| 533 | 533 | $jourmois = $nommois; |
| 534 | 534 | } |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | if ($annee < 0) { |
| 541 | - $annee = -$annee . " " . _T('date_avant_jc'); |
|
| 541 | + $annee = -$annee." "._T('date_avant_jc'); |
|
| 542 | 542 | $avjc = true; |
| 543 | 543 | } else { |
| 544 | 544 | $avjc = false; |
@@ -564,10 +564,10 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | if ($vue == 'saison') { |
| 567 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 567 | + return $saison ? _T('date_saison_'.$saison) : ''; |
|
| 568 | 568 | } else { |
| 569 | 569 | return $saison ? trim(_T('date_fmt_saison_annee', |
| 570 | - array('saison' => _T('date_saison_' . $saison), 'annee' => $annee))) : ''; |
|
| 570 | + array('saison' => _T('date_saison_'.$saison), 'annee' => $annee))) : ''; |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | case 'court': |
@@ -633,9 +633,9 @@ discard block |
||
| 633 | 633 | } |
| 634 | 634 | $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
| 635 | 635 | $nom = 1 + date('w', $nom); |
| 636 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 636 | + $param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : ''); |
|
| 637 | 637 | |
| 638 | - return _T('date_jour_' . $nom . $param); |
|
| 638 | + return _T('date_jour_'.$nom.$param); |
|
| 639 | 639 | |
| 640 | 640 | case 'mois_annee': |
| 641 | 641 | if ($avjc) { |
@@ -1030,8 +1030,8 @@ discard block |
||
| 1030 | 1030 | |
| 1031 | 1031 | $dtstart = $dtend = $dtabbr = ""; |
| 1032 | 1032 | if (strpos($forme, 'hcal') !== false) { |
| 1033 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1034 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1033 | + $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>"; |
|
| 1034 | + $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>"; |
|
| 1035 | 1035 | $dtabbr = "</abbr>"; |
| 1036 | 1036 | } |
| 1037 | 1037 | |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | } |
| 1076 | 1076 | } else { |
| 1077 | 1077 | if ($dtabbr && $dtstart) { |
| 1078 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1078 | + $s = $dtstart.spip_ucfirst($s).$dtabbr; |
|
| 1079 | 1079 | } else { |
| 1080 | 1080 | $s = spip_ucfirst($s); |
| 1081 | 1081 | } |
@@ -1098,8 +1098,8 @@ discard block |
||
| 1098 | 1098 | $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
| 1099 | 1099 | $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
| 1100 | 1100 | } |
| 1101 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1102 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1101 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1102 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1103 | 1103 | |
| 1104 | 1104 | $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
| 1105 | 1105 | } else { |
@@ -1116,8 +1116,8 @@ discard block |
||
| 1116 | 1116 | $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1120 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1119 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1120 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1121 | 1121 | $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
| 1122 | 1122 | |
| 1123 | 1123 | } |
@@ -1222,7 +1222,7 @@ discard block |
||
| 1222 | 1222 | $d = date("Y-m-d"); |
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1225 | + return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2); |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | /** |
@@ -1242,7 +1242,7 @@ discard block |
||
| 1242 | 1242 | $d = date("Y-m-d"); |
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1245 | + return substr($d, 0, 4).substr($d, 5, 2); |
|
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | /** |