@@ -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 | |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | * Date au format SQL tel que `2008-04-01` sinon '' |
| 38 | 38 | **/ |
| 39 | 39 | function extraire_date($texte): string { |
| 40 | - // format = 2001-08 |
|
| 41 | - if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
|
| 42 | - return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 43 | - } |
|
| 44 | - return ''; |
|
| 40 | + // format = 2001-08 |
|
| 41 | + if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
|
| 42 | + return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 43 | + } |
|
| 44 | + return ''; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -63,29 +63,29 @@ discard block |
||
| 63 | 63 | * - une chaîne vide si la date est considérée nulle |
| 64 | 64 | **/ |
| 65 | 65 | function normaliser_date($date, $forcer_jour = false) { |
| 66 | - $date = vider_date($date); |
|
| 67 | - if ($date) { |
|
| 68 | - if (preg_match('/^[0-9]{8,10}$/', $date)) { |
|
| 69 | - $date = date('Y-m-d H:i:s', $date); |
|
| 70 | - } |
|
| 71 | - if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 72 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 73 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 74 | - } else { |
|
| 75 | - if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 76 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 77 | - $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 78 | - } else { |
|
| 79 | - $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - if ($forcer_jour) { |
|
| 84 | - $date = str_replace('-00', '-01', $date); |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - return $date; |
|
| 66 | + $date = vider_date($date); |
|
| 67 | + if ($date) { |
|
| 68 | + if (preg_match('/^[0-9]{8,10}$/', $date)) { |
|
| 69 | + $date = date('Y-m-d H:i:s', $date); |
|
| 70 | + } |
|
| 71 | + if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 72 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 73 | + $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 74 | + } else { |
|
| 75 | + if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 76 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 77 | + $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 78 | + } else { |
|
| 79 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + if ($forcer_jour) { |
|
| 84 | + $date = str_replace('-00', '-01', $date); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + return $date; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -98,22 +98,22 @@ discard block |
||
| 98 | 98 | * - Une chaine vide |
| 99 | 99 | **/ |
| 100 | 100 | function vider_date($letexte, $verif_format_date = false) { |
| 101 | - if ( |
|
| 102 | - !$verif_format_date |
|
| 103 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 104 | - preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 105 | - ) { |
|
| 106 | - if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 107 | - return ''; |
|
| 108 | - } |
|
| 109 | - if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 110 | - return ''; |
|
| 111 | - } |
|
| 112 | - if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 113 | - return ''; |
|
| 114 | - } // eviter le bug GMT-1 |
|
| 115 | - } |
|
| 116 | - return $letexte; |
|
| 101 | + if ( |
|
| 102 | + !$verif_format_date |
|
| 103 | + or (in_array(strlen($letexte), [10,19]) and |
|
| 104 | + preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 105 | + ) { |
|
| 106 | + if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 107 | + return ''; |
|
| 108 | + } |
|
| 109 | + if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 110 | + return ''; |
|
| 111 | + } |
|
| 112 | + if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 113 | + return ''; |
|
| 114 | + } // eviter le bug GMT-1 |
|
| 115 | + } |
|
| 116 | + return $letexte; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | **/ |
| 130 | 130 | function recup_heure($date) { |
| 131 | 131 | |
| 132 | - static $d = [0, 0, 0]; |
|
| 133 | - if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 134 | - return $d; |
|
| 135 | - } |
|
| 132 | + static $d = [0, 0, 0]; |
|
| 133 | + if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 134 | + return $d; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - array_shift($r); |
|
| 137 | + array_shift($r); |
|
| 138 | 138 | |
| 139 | - return $r; |
|
| 139 | + return $r; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | * @return int heures, sinon 0 |
| 151 | 151 | **/ |
| 152 | 152 | function heures($numdate) { |
| 153 | - $heures = null; |
|
| 154 | - $date_array = recup_heure($numdate); |
|
| 155 | - if ($date_array) { |
|
| 156 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 157 | - } |
|
| 153 | + $heures = null; |
|
| 154 | + $date_array = recup_heure($numdate); |
|
| 155 | + if ($date_array) { |
|
| 156 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - return $heures; |
|
| 159 | + return $heures; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -170,13 +170,13 @@ discard block |
||
| 170 | 170 | * @return int minutes, sinon 0 |
| 171 | 171 | **/ |
| 172 | 172 | function minutes($numdate) { |
| 173 | - $minutes = null; |
|
| 174 | - $date_array = recup_heure($numdate); |
|
| 175 | - if ($date_array) { |
|
| 176 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 177 | - } |
|
| 173 | + $minutes = null; |
|
| 174 | + $date_array = recup_heure($numdate); |
|
| 175 | + if ($date_array) { |
|
| 176 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - return $minutes; |
|
| 179 | + return $minutes; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | * @return int secondes, sinon 0 |
| 191 | 191 | **/ |
| 192 | 192 | function secondes($numdate) { |
| 193 | - $secondes = null; |
|
| 194 | - $date_array = recup_heure($numdate); |
|
| 195 | - if ($date_array) { |
|
| 196 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 197 | - } |
|
| 193 | + $secondes = null; |
|
| 194 | + $date_array = recup_heure($numdate); |
|
| 195 | + if ($date_array) { |
|
| 196 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - return $secondes; |
|
| 199 | + return $secondes; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | * @return string L'heure formatée dans la langue en cours. |
| 216 | 216 | **/ |
| 217 | 217 | function heures_minutes($numdate, $forme = '') { |
| 218 | - if ($forme != 'abbr') { |
|
| 219 | - return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 220 | - } |
|
| 221 | - else { |
|
| 222 | - return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 223 | - } |
|
| 218 | + if ($forme != 'abbr') { |
|
| 219 | + return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 220 | + } |
|
| 221 | + else { |
|
| 222 | + return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 223 | + } |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -245,56 +245,56 @@ discard block |
||
| 245 | 245 | * @return array [année, mois, jour, heures, minutes, secondes] |
| 246 | 246 | **/ |
| 247 | 247 | function recup_date($numdate, $forcer_jour = true) { |
| 248 | - if (!$numdate) { |
|
| 249 | - return ''; |
|
| 250 | - } |
|
| 251 | - $heures = $minutes = $secondes = 0; |
|
| 252 | - if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 253 | - $jour = $regs[1]; |
|
| 254 | - $mois = $regs[2]; |
|
| 255 | - $annee = $regs[3]; |
|
| 256 | - if ($annee < 90) { |
|
| 257 | - $annee = 2000 + $annee; |
|
| 258 | - } elseif ($annee < 100) { |
|
| 259 | - $annee = 1900 + $annee; |
|
| 260 | - } |
|
| 261 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 262 | - } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 263 | - $annee = $regs[1]; |
|
| 264 | - $mois = $regs[2]; |
|
| 265 | - $jour = $regs[3]; |
|
| 266 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 267 | - } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 268 | - $annee = $regs[1]; |
|
| 269 | - $mois = $regs[2]; |
|
| 270 | - $jour = ''; |
|
| 271 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 272 | - } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 273 | - $annee = $regs[1]; |
|
| 274 | - $mois = $regs[2]; |
|
| 275 | - $jour = $regs[3]; |
|
| 276 | - $heures = $regs[4]; |
|
| 277 | - $minutes = $regs[5]; |
|
| 278 | - $secondes = $regs[6]; |
|
| 279 | - } else { |
|
| 280 | - $annee = $mois = $jour = ''; |
|
| 281 | - } |
|
| 282 | - if ($annee > 4000) { |
|
| 283 | - $annee -= 9000; |
|
| 284 | - } |
|
| 285 | - if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 286 | - $jour = substr($jour, 1); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - if ($forcer_jour and $jour == '0') { |
|
| 290 | - $jour = '1'; |
|
| 291 | - } |
|
| 292 | - if ($forcer_jour and $mois == '0') { |
|
| 293 | - $mois = '1'; |
|
| 294 | - } |
|
| 295 | - if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 296 | - return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 297 | - } |
|
| 248 | + if (!$numdate) { |
|
| 249 | + return ''; |
|
| 250 | + } |
|
| 251 | + $heures = $minutes = $secondes = 0; |
|
| 252 | + if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 253 | + $jour = $regs[1]; |
|
| 254 | + $mois = $regs[2]; |
|
| 255 | + $annee = $regs[3]; |
|
| 256 | + if ($annee < 90) { |
|
| 257 | + $annee = 2000 + $annee; |
|
| 258 | + } elseif ($annee < 100) { |
|
| 259 | + $annee = 1900 + $annee; |
|
| 260 | + } |
|
| 261 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 262 | + } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 263 | + $annee = $regs[1]; |
|
| 264 | + $mois = $regs[2]; |
|
| 265 | + $jour = $regs[3]; |
|
| 266 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 267 | + } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 268 | + $annee = $regs[1]; |
|
| 269 | + $mois = $regs[2]; |
|
| 270 | + $jour = ''; |
|
| 271 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 272 | + } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 273 | + $annee = $regs[1]; |
|
| 274 | + $mois = $regs[2]; |
|
| 275 | + $jour = $regs[3]; |
|
| 276 | + $heures = $regs[4]; |
|
| 277 | + $minutes = $regs[5]; |
|
| 278 | + $secondes = $regs[6]; |
|
| 279 | + } else { |
|
| 280 | + $annee = $mois = $jour = ''; |
|
| 281 | + } |
|
| 282 | + if ($annee > 4000) { |
|
| 283 | + $annee -= 9000; |
|
| 284 | + } |
|
| 285 | + if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 286 | + $jour = substr($jour, 1); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + if ($forcer_jour and $jour == '0') { |
|
| 290 | + $jour = '1'; |
|
| 291 | + } |
|
| 292 | + if ($forcer_jour and $mois == '0') { |
|
| 293 | + $mois = '1'; |
|
| 294 | + } |
|
| 295 | + if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 296 | + return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 297 | + } |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | * La date relative ou complète |
| 322 | 322 | **/ |
| 323 | 323 | function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */) { |
| 324 | - return sinon( |
|
| 325 | - date_relative($date, $decalage_maxi), |
|
| 326 | - affdate_heure($date) |
|
| 327 | - ); |
|
| 324 | + return sinon( |
|
| 325 | + date_relative($date, $decalage_maxi), |
|
| 326 | + affdate_heure($date) |
|
| 327 | + ); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -357,85 +357,85 @@ discard block |
||
| 357 | 357 | **/ |
| 358 | 358 | function date_relative($date, $decalage_maxi = 0, $ref_date = null) { |
| 359 | 359 | |
| 360 | - if (is_null($ref_date)) { |
|
| 361 | - $ref_time = time(); |
|
| 362 | - } else { |
|
| 363 | - $ref_time = strtotime($ref_date); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - if (!$date) { |
|
| 367 | - return; |
|
| 368 | - } |
|
| 369 | - $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 370 | - |
|
| 371 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 372 | - return ''; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - if ($decal < 0) { |
|
| 376 | - $il_y_a = 'date_dans'; |
|
| 377 | - $decal = -1 * $decal; |
|
| 378 | - } else { |
|
| 379 | - $il_y_a = 'date_il_y_a'; |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - if ($decal > 3600 * 24 * 30 * 6) { |
|
| 383 | - return affdate_court($date); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - if ($decal > 3600 * 24 * 30) { |
|
| 387 | - $mois = floor($decal / (3600 * 24 * 30)); |
|
| 388 | - if ($mois < 2) { |
|
| 389 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 390 | - } else { |
|
| 391 | - $delai = "$mois " . _T('date_mois'); |
|
| 392 | - } |
|
| 393 | - } else { |
|
| 394 | - if ($decal > 3600 * 24 * 7) { |
|
| 395 | - $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 396 | - if ($semaines < 2) { |
|
| 397 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 398 | - } else { |
|
| 399 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 400 | - } |
|
| 401 | - } else { |
|
| 402 | - if ($decal > 3600 * 24) { |
|
| 403 | - $jours = floor($decal / (3600 * 24)); |
|
| 404 | - if ($jours < 2) { |
|
| 405 | - return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 406 | - } else { |
|
| 407 | - $delai = "$jours " . _T('date_jours'); |
|
| 408 | - } |
|
| 409 | - } else { |
|
| 410 | - if ($decal >= 3600) { |
|
| 411 | - $heures = floor($decal / 3600); |
|
| 412 | - if ($heures < 2) { |
|
| 413 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 414 | - } else { |
|
| 415 | - $delai = "$heures " . _T('date_heures'); |
|
| 416 | - } |
|
| 417 | - } else { |
|
| 418 | - if ($decal >= 60) { |
|
| 419 | - $minutes = floor($decal / 60); |
|
| 420 | - if ($minutes < 2) { |
|
| 421 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 422 | - } else { |
|
| 423 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 424 | - } |
|
| 425 | - } else { |
|
| 426 | - $secondes = ceil($decal); |
|
| 427 | - if ($secondes < 2) { |
|
| 428 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 429 | - } else { |
|
| 430 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - return _T($il_y_a, ['delai' => $delai]); |
|
| 360 | + if (is_null($ref_date)) { |
|
| 361 | + $ref_time = time(); |
|
| 362 | + } else { |
|
| 363 | + $ref_time = strtotime($ref_date); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + if (!$date) { |
|
| 367 | + return; |
|
| 368 | + } |
|
| 369 | + $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 370 | + |
|
| 371 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 372 | + return ''; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + if ($decal < 0) { |
|
| 376 | + $il_y_a = 'date_dans'; |
|
| 377 | + $decal = -1 * $decal; |
|
| 378 | + } else { |
|
| 379 | + $il_y_a = 'date_il_y_a'; |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + if ($decal > 3600 * 24 * 30 * 6) { |
|
| 383 | + return affdate_court($date); |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + if ($decal > 3600 * 24 * 30) { |
|
| 387 | + $mois = floor($decal / (3600 * 24 * 30)); |
|
| 388 | + if ($mois < 2) { |
|
| 389 | + $delai = "$mois " . _T('date_un_mois'); |
|
| 390 | + } else { |
|
| 391 | + $delai = "$mois " . _T('date_mois'); |
|
| 392 | + } |
|
| 393 | + } else { |
|
| 394 | + if ($decal > 3600 * 24 * 7) { |
|
| 395 | + $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 396 | + if ($semaines < 2) { |
|
| 397 | + $delai = "$semaines " . _T('date_une_semaine'); |
|
| 398 | + } else { |
|
| 399 | + $delai = "$semaines " . _T('date_semaines'); |
|
| 400 | + } |
|
| 401 | + } else { |
|
| 402 | + if ($decal > 3600 * 24) { |
|
| 403 | + $jours = floor($decal / (3600 * 24)); |
|
| 404 | + if ($jours < 2) { |
|
| 405 | + return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 406 | + } else { |
|
| 407 | + $delai = "$jours " . _T('date_jours'); |
|
| 408 | + } |
|
| 409 | + } else { |
|
| 410 | + if ($decal >= 3600) { |
|
| 411 | + $heures = floor($decal / 3600); |
|
| 412 | + if ($heures < 2) { |
|
| 413 | + $delai = "$heures " . _T('date_une_heure'); |
|
| 414 | + } else { |
|
| 415 | + $delai = "$heures " . _T('date_heures'); |
|
| 416 | + } |
|
| 417 | + } else { |
|
| 418 | + if ($decal >= 60) { |
|
| 419 | + $minutes = floor($decal / 60); |
|
| 420 | + if ($minutes < 2) { |
|
| 421 | + $delai = "$minutes " . _T('date_une_minute'); |
|
| 422 | + } else { |
|
| 423 | + $delai = "$minutes " . _T('date_minutes'); |
|
| 424 | + } |
|
| 425 | + } else { |
|
| 426 | + $secondes = ceil($decal); |
|
| 427 | + if ($secondes < 2) { |
|
| 428 | + $delai = "$secondes " . _T('date_une_seconde'); |
|
| 429 | + } else { |
|
| 430 | + $delai = "$secondes " . _T('date_secondes'); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + return _T($il_y_a, ['delai' => $delai]); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
@@ -461,32 +461,32 @@ discard block |
||
| 461 | 461 | **/ |
| 462 | 462 | function date_relativecourt($date, $decalage_maxi = 0) { |
| 463 | 463 | |
| 464 | - if (!$date) { |
|
| 465 | - return; |
|
| 466 | - } |
|
| 467 | - $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 468 | - |
|
| 469 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 470 | - return ''; |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - if ($decal < -24 * 3600) { |
|
| 474 | - $retour = date_relative($date, $decalage_maxi); |
|
| 475 | - } elseif ($decal < 0) { |
|
| 476 | - $retour = _T('date_demain'); |
|
| 477 | - } else { |
|
| 478 | - if ($decal < (3600 * 24)) { |
|
| 479 | - $retour = _T('date_aujourdhui'); |
|
| 480 | - } else { |
|
| 481 | - if ($decal < (3600 * 24 * 2)) { |
|
| 482 | - $retour = _T('date_hier'); |
|
| 483 | - } else { |
|
| 484 | - $retour = date_relative($date, $decalage_maxi); |
|
| 485 | - } |
|
| 486 | - } |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - return $retour; |
|
| 464 | + if (!$date) { |
|
| 465 | + return; |
|
| 466 | + } |
|
| 467 | + $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 468 | + |
|
| 469 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 470 | + return ''; |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + if ($decal < -24 * 3600) { |
|
| 474 | + $retour = date_relative($date, $decalage_maxi); |
|
| 475 | + } elseif ($decal < 0) { |
|
| 476 | + $retour = _T('date_demain'); |
|
| 477 | + } else { |
|
| 478 | + if ($decal < (3600 * 24)) { |
|
| 479 | + $retour = _T('date_aujourdhui'); |
|
| 480 | + } else { |
|
| 481 | + if ($decal < (3600 * 24 * 2)) { |
|
| 482 | + $retour = _T('date_hier'); |
|
| 483 | + } else { |
|
| 484 | + $retour = date_relative($date, $decalage_maxi); |
|
| 485 | + } |
|
| 486 | + } |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + return $retour; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -503,174 +503,174 @@ discard block |
||
| 503 | 503 | * @return mixed|string |
| 504 | 504 | */ |
| 505 | 505 | function affdate_base($numdate, $vue, $options = []) { |
| 506 | - if (is_string($options)) { |
|
| 507 | - $options = ['param' => $options]; |
|
| 508 | - } |
|
| 509 | - $date_array = recup_date($numdate, false); |
|
| 510 | - if (!$date_array) { |
|
| 511 | - return; |
|
| 512 | - } |
|
| 513 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 514 | - |
|
| 515 | - // 1er, 21st, etc. |
|
| 516 | - $journum = $jour; |
|
| 517 | - |
|
| 518 | - if ($jour == 0) { |
|
| 519 | - $jour = ''; |
|
| 520 | - $njour = 0; |
|
| 521 | - } else { |
|
| 522 | - $njour = intval($jour); |
|
| 523 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 524 | - $jour = $jourth; |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - $mois = intval($mois); |
|
| 529 | - if ($mois > 0 and $mois < 13) { |
|
| 530 | - /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 531 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 532 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 533 | - if ($jour) { |
|
| 534 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 535 | - } else { |
|
| 536 | - $jourmois = $nommois; |
|
| 537 | - } |
|
| 538 | - } else { |
|
| 539 | - $nommois = ''; |
|
| 540 | - $jourmois = ''; |
|
| 541 | - } |
|
| 542 | - |
|
| 543 | - if ($annee < 0) { |
|
| 544 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 545 | - $avjc = true; |
|
| 546 | - } else { |
|
| 547 | - $avjc = false; |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - switch ($vue) { |
|
| 551 | - case 'saison': |
|
| 552 | - case 'saison_annee': |
|
| 553 | - $saison = ''; |
|
| 554 | - if ($mois > 0) { |
|
| 555 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 556 | - if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 557 | - $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 558 | - } |
|
| 559 | - if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 560 | - $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 561 | - } |
|
| 562 | - if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 563 | - $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 564 | - } |
|
| 565 | - if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 566 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 567 | - } |
|
| 568 | - } |
|
| 569 | - if ($vue == 'saison') { |
|
| 570 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 571 | - } else { |
|
| 572 | - return $saison ? trim(_T( |
|
| 573 | - 'date_fmt_saison_annee', |
|
| 574 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 575 | - )) : ''; |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - case 'court': |
|
| 579 | - if ($avjc) { |
|
| 580 | - return $annee; |
|
| 581 | - } |
|
| 582 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 583 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 584 | - return $annee; |
|
| 585 | - } |
|
| 586 | - if ($annee != $a) { |
|
| 587 | - return _T( |
|
| 588 | - 'date_fmt_mois_annee', |
|
| 589 | - ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 590 | - ); |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - return _T( |
|
| 594 | - 'date_fmt_jour_mois', |
|
| 595 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 596 | - ); |
|
| 597 | - |
|
| 598 | - case 'jourcourt': |
|
| 599 | - if ($avjc) { |
|
| 600 | - return $annee; |
|
| 601 | - } |
|
| 602 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 603 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 604 | - return $annee; |
|
| 605 | - } |
|
| 606 | - if ($annee != $a) { |
|
| 607 | - return _T( |
|
| 608 | - 'date_fmt_jour_mois_annee', |
|
| 609 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 610 | - ); |
|
| 611 | - } |
|
| 612 | - |
|
| 613 | - return _T( |
|
| 614 | - 'date_fmt_jour_mois', |
|
| 615 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 616 | - ); |
|
| 617 | - |
|
| 618 | - case 'entier': |
|
| 619 | - if ($avjc) { |
|
| 620 | - return $annee; |
|
| 621 | - } |
|
| 622 | - if ($jour) { |
|
| 623 | - return _T( |
|
| 624 | - 'date_fmt_jour_mois_annee', |
|
| 625 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 626 | - ); |
|
| 627 | - } elseif ($mois) { |
|
| 628 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 629 | - } else { |
|
| 630 | - return $annee; |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - case 'nom_mois': |
|
| 634 | - return $nommois; |
|
| 635 | - |
|
| 636 | - case 'mois': |
|
| 637 | - return sprintf('%02s', $mois); |
|
| 638 | - |
|
| 639 | - case 'jour': |
|
| 640 | - return $jour; |
|
| 641 | - |
|
| 642 | - case 'journum': |
|
| 643 | - return $journum; |
|
| 644 | - |
|
| 645 | - case 'nom_jour': |
|
| 646 | - if (!$mois or !$njour) { |
|
| 647 | - return ''; |
|
| 648 | - } |
|
| 649 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 650 | - $nom = 1 + date('w', $nom); |
|
| 651 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 652 | - |
|
| 653 | - return _T('date_jour_' . $nom . $param); |
|
| 654 | - |
|
| 655 | - case 'mois_annee': |
|
| 656 | - if ($avjc) { |
|
| 657 | - return $annee; |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 661 | - |
|
| 662 | - case 'annee': |
|
| 663 | - return $annee; |
|
| 664 | - |
|
| 665 | - // Cas d'une vue non definie : retomber sur le format |
|
| 666 | - // de date propose par http://www.php.net/date |
|
| 667 | - default: |
|
| 668 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 669 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) { |
|
| 670 | - $time = strtotime($numdate); |
|
| 671 | - } |
|
| 672 | - return date($vue, $time); |
|
| 673 | - } |
|
| 506 | + if (is_string($options)) { |
|
| 507 | + $options = ['param' => $options]; |
|
| 508 | + } |
|
| 509 | + $date_array = recup_date($numdate, false); |
|
| 510 | + if (!$date_array) { |
|
| 511 | + return; |
|
| 512 | + } |
|
| 513 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 514 | + |
|
| 515 | + // 1er, 21st, etc. |
|
| 516 | + $journum = $jour; |
|
| 517 | + |
|
| 518 | + if ($jour == 0) { |
|
| 519 | + $jour = ''; |
|
| 520 | + $njour = 0; |
|
| 521 | + } else { |
|
| 522 | + $njour = intval($jour); |
|
| 523 | + if ($jourth = _T('date_jnum' . $jour)) { |
|
| 524 | + $jour = $jourth; |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + $mois = intval($mois); |
|
| 529 | + if ($mois > 0 and $mois < 13) { |
|
| 530 | + /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 531 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 532 | + $nommois = _T('date_mois_' . $mois . $param); |
|
| 533 | + if ($jour) { |
|
| 534 | + $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 535 | + } else { |
|
| 536 | + $jourmois = $nommois; |
|
| 537 | + } |
|
| 538 | + } else { |
|
| 539 | + $nommois = ''; |
|
| 540 | + $jourmois = ''; |
|
| 541 | + } |
|
| 542 | + |
|
| 543 | + if ($annee < 0) { |
|
| 544 | + $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 545 | + $avjc = true; |
|
| 546 | + } else { |
|
| 547 | + $avjc = false; |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + switch ($vue) { |
|
| 551 | + case 'saison': |
|
| 552 | + case 'saison_annee': |
|
| 553 | + $saison = ''; |
|
| 554 | + if ($mois > 0) { |
|
| 555 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 556 | + if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 557 | + $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 558 | + } |
|
| 559 | + if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 560 | + $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 561 | + } |
|
| 562 | + if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 563 | + $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 564 | + } |
|
| 565 | + if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 566 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | + if ($vue == 'saison') { |
|
| 570 | + return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 571 | + } else { |
|
| 572 | + return $saison ? trim(_T( |
|
| 573 | + 'date_fmt_saison_annee', |
|
| 574 | + ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 575 | + )) : ''; |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + case 'court': |
|
| 579 | + if ($avjc) { |
|
| 580 | + return $annee; |
|
| 581 | + } |
|
| 582 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 583 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 584 | + return $annee; |
|
| 585 | + } |
|
| 586 | + if ($annee != $a) { |
|
| 587 | + return _T( |
|
| 588 | + 'date_fmt_mois_annee', |
|
| 589 | + ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 590 | + ); |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + return _T( |
|
| 594 | + 'date_fmt_jour_mois', |
|
| 595 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 596 | + ); |
|
| 597 | + |
|
| 598 | + case 'jourcourt': |
|
| 599 | + if ($avjc) { |
|
| 600 | + return $annee; |
|
| 601 | + } |
|
| 602 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 603 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 604 | + return $annee; |
|
| 605 | + } |
|
| 606 | + if ($annee != $a) { |
|
| 607 | + return _T( |
|
| 608 | + 'date_fmt_jour_mois_annee', |
|
| 609 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 610 | + ); |
|
| 611 | + } |
|
| 612 | + |
|
| 613 | + return _T( |
|
| 614 | + 'date_fmt_jour_mois', |
|
| 615 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 616 | + ); |
|
| 617 | + |
|
| 618 | + case 'entier': |
|
| 619 | + if ($avjc) { |
|
| 620 | + return $annee; |
|
| 621 | + } |
|
| 622 | + if ($jour) { |
|
| 623 | + return _T( |
|
| 624 | + 'date_fmt_jour_mois_annee', |
|
| 625 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 626 | + ); |
|
| 627 | + } elseif ($mois) { |
|
| 628 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 629 | + } else { |
|
| 630 | + return $annee; |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + case 'nom_mois': |
|
| 634 | + return $nommois; |
|
| 635 | + |
|
| 636 | + case 'mois': |
|
| 637 | + return sprintf('%02s', $mois); |
|
| 638 | + |
|
| 639 | + case 'jour': |
|
| 640 | + return $jour; |
|
| 641 | + |
|
| 642 | + case 'journum': |
|
| 643 | + return $journum; |
|
| 644 | + |
|
| 645 | + case 'nom_jour': |
|
| 646 | + if (!$mois or !$njour) { |
|
| 647 | + return ''; |
|
| 648 | + } |
|
| 649 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 650 | + $nom = 1 + date('w', $nom); |
|
| 651 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 652 | + |
|
| 653 | + return _T('date_jour_' . $nom . $param); |
|
| 654 | + |
|
| 655 | + case 'mois_annee': |
|
| 656 | + if ($avjc) { |
|
| 657 | + return $annee; |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 661 | + |
|
| 662 | + case 'annee': |
|
| 663 | + return $annee; |
|
| 664 | + |
|
| 665 | + // Cas d'une vue non definie : retomber sur le format |
|
| 666 | + // de date propose par http://www.php.net/date |
|
| 667 | + default: |
|
| 668 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 669 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) { |
|
| 670 | + $time = strtotime($numdate); |
|
| 671 | + } |
|
| 672 | + return date($vue, $time); |
|
| 673 | + } |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | |
@@ -697,11 +697,11 @@ discard block |
||
| 697 | 697 | * Nom du jour |
| 698 | 698 | **/ |
| 699 | 699 | function nom_jour($numdate, $forme = '') { |
| 700 | - if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 701 | - $forme = ''; |
|
| 702 | - } |
|
| 700 | + if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 701 | + $forme = ''; |
|
| 702 | + } |
|
| 703 | 703 | |
| 704 | - return affdate_base($numdate, 'nom_jour', $forme); |
|
| 704 | + return affdate_base($numdate, 'nom_jour', $forme); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | /** |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | * Numéro du jour |
| 724 | 724 | **/ |
| 725 | 725 | function jour($numdate) { |
| 726 | - return affdate_base($numdate, 'jour'); |
|
| 726 | + return affdate_base($numdate, 'jour'); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | /** |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | * Numéro du jour |
| 742 | 742 | **/ |
| 743 | 743 | function journum($numdate) { |
| 744 | - return affdate_base($numdate, 'journum'); |
|
| 744 | + return affdate_base($numdate, 'journum'); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | /** |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | * Numéro du mois (sur 2 chiffres) |
| 760 | 760 | **/ |
| 761 | 761 | function mois($numdate) { |
| 762 | - return affdate_base($numdate, 'mois'); |
|
| 762 | + return affdate_base($numdate, 'mois'); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | /** |
@@ -783,11 +783,11 @@ discard block |
||
| 783 | 783 | * Nom du mois |
| 784 | 784 | **/ |
| 785 | 785 | function nom_mois($numdate, $forme = '') { |
| 786 | - if (!($forme == 'abbr')) { |
|
| 787 | - $forme = ''; |
|
| 788 | - } |
|
| 786 | + if (!($forme == 'abbr')) { |
|
| 787 | + $forme = ''; |
|
| 788 | + } |
|
| 789 | 789 | |
| 790 | - return affdate_base($numdate, 'nom_mois', $forme); |
|
| 790 | + return affdate_base($numdate, 'nom_mois', $forme); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | * Année (sur 4 chiffres) |
| 806 | 806 | **/ |
| 807 | 807 | function annee($numdate) { |
| 808 | - return affdate_base($numdate, 'annee'); |
|
| 808 | + return affdate_base($numdate, 'annee'); |
|
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | |
@@ -835,11 +835,11 @@ discard block |
||
| 835 | 835 | * La date formatée |
| 836 | 836 | **/ |
| 837 | 837 | function saison($numdate, $hemisphere = 'nord') { |
| 838 | - if ($hemisphere != 'sud') { |
|
| 839 | - $hemisphere = 'nord'; |
|
| 840 | - } |
|
| 838 | + if ($hemisphere != 'sud') { |
|
| 839 | + $hemisphere = 'nord'; |
|
| 840 | + } |
|
| 841 | 841 | |
| 842 | - return affdate_base($numdate, 'saison', $hemisphere); |
|
| 842 | + return affdate_base($numdate, 'saison', $hemisphere); |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | 845 | |
@@ -868,11 +868,11 @@ discard block |
||
| 868 | 868 | * La date formatée |
| 869 | 869 | **/ |
| 870 | 870 | function saison_annee($numdate, $hemisphere = 'nord') { |
| 871 | - if ($hemisphere != 'sud') { |
|
| 872 | - $hemisphere = 'nord'; |
|
| 873 | - } |
|
| 871 | + if ($hemisphere != 'sud') { |
|
| 872 | + $hemisphere = 'nord'; |
|
| 873 | + } |
|
| 874 | 874 | |
| 875 | - return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 875 | + return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | /** |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | * La date formatée |
| 901 | 901 | **/ |
| 902 | 902 | function affdate($numdate, $format = 'entier') { |
| 903 | - return affdate_base($numdate, $format); |
|
| 903 | + return affdate_base($numdate, $format); |
|
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | * La date formatée |
| 928 | 928 | **/ |
| 929 | 929 | function affdate_court($numdate, $annee_courante = null) { |
| 930 | - return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 930 | + return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | * La date formatée |
| 955 | 955 | **/ |
| 956 | 956 | function affdate_jourcourt($numdate, $annee_courante = null) { |
| 957 | - return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 957 | + return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | /** |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | * La date formatée |
| 973 | 973 | **/ |
| 974 | 974 | function affdate_mois_annee($numdate) { |
| 975 | - return affdate_base($numdate, 'mois_annee'); |
|
| 975 | + return affdate_base($numdate, 'mois_annee'); |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | /** |
@@ -990,16 +990,16 @@ discard block |
||
| 990 | 990 | * La date formatée |
| 991 | 991 | **/ |
| 992 | 992 | function affdate_heure($numdate) { |
| 993 | - $date_array = recup_date($numdate); |
|
| 994 | - if (!$date_array) { |
|
| 995 | - return; |
|
| 996 | - } |
|
| 997 | - [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 998 | - |
|
| 999 | - return _T('date_fmt_jour_heure', [ |
|
| 1000 | - 'jour' => affdate($numdate), |
|
| 1001 | - 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 1002 | - ]); |
|
| 993 | + $date_array = recup_date($numdate); |
|
| 994 | + if (!$date_array) { |
|
| 995 | + return; |
|
| 996 | + } |
|
| 997 | + [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 998 | + |
|
| 999 | + return _T('date_fmt_jour_heure', [ |
|
| 1000 | + 'jour' => affdate($numdate), |
|
| 1001 | + 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 1002 | + ]); |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | /** |
@@ -1031,117 +1031,117 @@ discard block |
||
| 1031 | 1031 | * Texte de la date |
| 1032 | 1032 | */ |
| 1033 | 1033 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = '') { |
| 1034 | - $abbr = $jour = ''; |
|
| 1035 | - $affdate = 'affdate_jourcourt'; |
|
| 1036 | - if (strpos($forme, 'abbr') !== false) { |
|
| 1037 | - $abbr = 'abbr'; |
|
| 1038 | - } |
|
| 1039 | - if (strpos($forme, 'annee') !== false) { |
|
| 1040 | - $affdate = 'affdate'; |
|
| 1041 | - } |
|
| 1042 | - if (strpos($forme, 'jour') !== false) { |
|
| 1043 | - $jour = 'jour'; |
|
| 1044 | - } |
|
| 1045 | - |
|
| 1046 | - $dtstart = $dtend = $dtabbr = ''; |
|
| 1047 | - if (strpos($forme, 'hcal') !== false) { |
|
| 1048 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1049 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1050 | - $dtabbr = '</abbr>'; |
|
| 1051 | - } |
|
| 1052 | - |
|
| 1053 | - $date_debut = strtotime($date_debut); |
|
| 1054 | - $date_fin = strtotime($date_fin); |
|
| 1055 | - $d = date('Y-m-d', $date_debut); |
|
| 1056 | - $f = date('Y-m-d', $date_fin); |
|
| 1057 | - $h = ($horaire === 'oui' or $horaire === true); |
|
| 1058 | - $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1059 | - $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1060 | - |
|
| 1061 | - if ($d == $f) { // meme jour |
|
| 1062 | - $nomjour = nom_jour($d, $abbr); |
|
| 1063 | - $s = $affdate($d); |
|
| 1064 | - $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1065 | - if ($h) { |
|
| 1066 | - if ($hd == $hf) { |
|
| 1067 | - // Lundi 20 fevrier a 18h25 |
|
| 1068 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1069 | - $s = "$dtstart$s$dtabbr"; |
|
| 1070 | - } else { |
|
| 1071 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1072 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1073 | - $s = _T( |
|
| 1074 | - 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1075 | - [ |
|
| 1076 | - 'jour' => spip_ucfirst($s), |
|
| 1077 | - 'heure_debut' => $hd, |
|
| 1078 | - 'heure_fin' => $hf, |
|
| 1079 | - 'dtstart' => $dtstart, |
|
| 1080 | - 'dtend' => $dtend, |
|
| 1081 | - 'dtabbr' => $dtabbr |
|
| 1082 | - ], |
|
| 1083 | - [ |
|
| 1084 | - 'sanitize' => false |
|
| 1085 | - ] |
|
| 1086 | - ); |
|
| 1087 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1088 | - else { |
|
| 1089 | - $s = spip_ucfirst(_T( |
|
| 1090 | - 'date_fmt_jour_heure_debut_fin', |
|
| 1091 | - ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1092 | - )); |
|
| 1093 | - } |
|
| 1094 | - } |
|
| 1095 | - } else { |
|
| 1096 | - if ($dtabbr && $dtstart) { |
|
| 1097 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1098 | - } else { |
|
| 1099 | - $s = spip_ucfirst($s); |
|
| 1100 | - } |
|
| 1101 | - } |
|
| 1102 | - } else { |
|
| 1103 | - if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1104 | - if (!$h) { |
|
| 1105 | - $date_debut = jour($d); |
|
| 1106 | - } else { |
|
| 1107 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1108 | - } |
|
| 1109 | - $date_fin = $affdate($f); |
|
| 1110 | - if ($jour) { |
|
| 1111 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1112 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1113 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1114 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1115 | - } |
|
| 1116 | - if ($h) { |
|
| 1117 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1118 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1119 | - } |
|
| 1120 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1121 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1122 | - |
|
| 1123 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1124 | - } else { |
|
| 1125 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1126 | - $date_fin = $affdate($f); |
|
| 1127 | - if ($jour) { |
|
| 1128 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1129 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1130 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1131 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1132 | - } |
|
| 1133 | - if ($h) { |
|
| 1134 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1135 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1136 | - } |
|
| 1137 | - |
|
| 1138 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1139 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1140 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1141 | - } |
|
| 1142 | - } |
|
| 1143 | - |
|
| 1144 | - return $s; |
|
| 1034 | + $abbr = $jour = ''; |
|
| 1035 | + $affdate = 'affdate_jourcourt'; |
|
| 1036 | + if (strpos($forme, 'abbr') !== false) { |
|
| 1037 | + $abbr = 'abbr'; |
|
| 1038 | + } |
|
| 1039 | + if (strpos($forme, 'annee') !== false) { |
|
| 1040 | + $affdate = 'affdate'; |
|
| 1041 | + } |
|
| 1042 | + if (strpos($forme, 'jour') !== false) { |
|
| 1043 | + $jour = 'jour'; |
|
| 1044 | + } |
|
| 1045 | + |
|
| 1046 | + $dtstart = $dtend = $dtabbr = ''; |
|
| 1047 | + if (strpos($forme, 'hcal') !== false) { |
|
| 1048 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1049 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1050 | + $dtabbr = '</abbr>'; |
|
| 1051 | + } |
|
| 1052 | + |
|
| 1053 | + $date_debut = strtotime($date_debut); |
|
| 1054 | + $date_fin = strtotime($date_fin); |
|
| 1055 | + $d = date('Y-m-d', $date_debut); |
|
| 1056 | + $f = date('Y-m-d', $date_fin); |
|
| 1057 | + $h = ($horaire === 'oui' or $horaire === true); |
|
| 1058 | + $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1059 | + $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1060 | + |
|
| 1061 | + if ($d == $f) { // meme jour |
|
| 1062 | + $nomjour = nom_jour($d, $abbr); |
|
| 1063 | + $s = $affdate($d); |
|
| 1064 | + $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1065 | + if ($h) { |
|
| 1066 | + if ($hd == $hf) { |
|
| 1067 | + // Lundi 20 fevrier a 18h25 |
|
| 1068 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1069 | + $s = "$dtstart$s$dtabbr"; |
|
| 1070 | + } else { |
|
| 1071 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1072 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1073 | + $s = _T( |
|
| 1074 | + 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1075 | + [ |
|
| 1076 | + 'jour' => spip_ucfirst($s), |
|
| 1077 | + 'heure_debut' => $hd, |
|
| 1078 | + 'heure_fin' => $hf, |
|
| 1079 | + 'dtstart' => $dtstart, |
|
| 1080 | + 'dtend' => $dtend, |
|
| 1081 | + 'dtabbr' => $dtabbr |
|
| 1082 | + ], |
|
| 1083 | + [ |
|
| 1084 | + 'sanitize' => false |
|
| 1085 | + ] |
|
| 1086 | + ); |
|
| 1087 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1088 | + else { |
|
| 1089 | + $s = spip_ucfirst(_T( |
|
| 1090 | + 'date_fmt_jour_heure_debut_fin', |
|
| 1091 | + ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1092 | + )); |
|
| 1093 | + } |
|
| 1094 | + } |
|
| 1095 | + } else { |
|
| 1096 | + if ($dtabbr && $dtstart) { |
|
| 1097 | + $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1098 | + } else { |
|
| 1099 | + $s = spip_ucfirst($s); |
|
| 1100 | + } |
|
| 1101 | + } |
|
| 1102 | + } else { |
|
| 1103 | + if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1104 | + if (!$h) { |
|
| 1105 | + $date_debut = jour($d); |
|
| 1106 | + } else { |
|
| 1107 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1108 | + } |
|
| 1109 | + $date_fin = $affdate($f); |
|
| 1110 | + if ($jour) { |
|
| 1111 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1112 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1113 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1114 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1115 | + } |
|
| 1116 | + if ($h) { |
|
| 1117 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1118 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1119 | + } |
|
| 1120 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1121 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1122 | + |
|
| 1123 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1124 | + } else { |
|
| 1125 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1126 | + $date_fin = $affdate($f); |
|
| 1127 | + if ($jour) { |
|
| 1128 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1129 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1130 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1131 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1132 | + } |
|
| 1133 | + if ($h) { |
|
| 1134 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1135 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1136 | + } |
|
| 1137 | + |
|
| 1138 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1139 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1140 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1141 | + } |
|
| 1142 | + } |
|
| 1143 | + |
|
| 1144 | + return $s; |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | /** |
@@ -1162,10 +1162,10 @@ discard block |
||
| 1162 | 1162 | * Date au format ical |
| 1163 | 1163 | **/ |
| 1164 | 1164 | function date_ical($date, $addminutes = 0) { |
| 1165 | - [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1166 | - [$annee, $mois, $jour] = recup_date($date); |
|
| 1165 | + [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1166 | + [$annee, $mois, $jour] = recup_date($date); |
|
| 1167 | 1167 | |
| 1168 | - return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1168 | + return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | |
@@ -1189,11 +1189,11 @@ discard block |
||
| 1189 | 1189 | * La date formatée |
| 1190 | 1190 | **/ |
| 1191 | 1191 | function date_iso($date_heure) { |
| 1192 | - [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1193 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1194 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1192 | + [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1193 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1194 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1195 | 1195 | |
| 1196 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1196 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | /** |
@@ -1216,11 +1216,11 @@ discard block |
||
| 1216 | 1216 | * La date formatée |
| 1217 | 1217 | **/ |
| 1218 | 1218 | function date_822($date_heure) { |
| 1219 | - [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1220 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1221 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1219 | + [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1220 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1221 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1222 | 1222 | |
| 1223 | - return date('r', $time); |
|
| 1223 | + return date('r', $time); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | /** |
@@ -1236,11 +1236,11 @@ discard block |
||
| 1236 | 1236 | * Date au format `Ymd` |
| 1237 | 1237 | **/ |
| 1238 | 1238 | function date_anneemoisjour($d) { |
| 1239 | - if (!$d) { |
|
| 1240 | - $d = date('Y-m-d'); |
|
| 1241 | - } |
|
| 1239 | + if (!$d) { |
|
| 1240 | + $d = date('Y-m-d'); |
|
| 1241 | + } |
|
| 1242 | 1242 | |
| 1243 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1243 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | /** |
@@ -1256,11 +1256,11 @@ discard block |
||
| 1256 | 1256 | * Date au format `Ym` |
| 1257 | 1257 | **/ |
| 1258 | 1258 | function date_anneemois($d) { |
| 1259 | - if (!$d) { |
|
| 1260 | - $d = date('Y-m-d'); |
|
| 1261 | - } |
|
| 1259 | + if (!$d) { |
|
| 1260 | + $d = date('Y-m-d'); |
|
| 1261 | + } |
|
| 1262 | 1262 | |
| 1263 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1263 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | /** |
@@ -1276,13 +1276,13 @@ discard block |
||
| 1276 | 1276 | * Date au lundi de la même semaine au format `Ymd` |
| 1277 | 1277 | **/ |
| 1278 | 1278 | function date_debut_semaine($annee, $mois, $jour) { |
| 1279 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1280 | - if ($w_day == 0) { |
|
| 1281 | - $w_day = 7; |
|
| 1282 | - } // Gaffe: le dimanche est zero |
|
| 1283 | - $debut = $jour - $w_day + 1; |
|
| 1279 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1280 | + if ($w_day == 0) { |
|
| 1281 | + $w_day = 7; |
|
| 1282 | + } // Gaffe: le dimanche est zero |
|
| 1283 | + $debut = $jour - $w_day + 1; |
|
| 1284 | 1284 | |
| 1285 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1285 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | /** |
@@ -1298,11 +1298,11 @@ discard block |
||
| 1298 | 1298 | * Date au dimanche de la même semaine au format `Ymd` |
| 1299 | 1299 | **/ |
| 1300 | 1300 | function date_fin_semaine($annee, $mois, $jour) { |
| 1301 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1302 | - if ($w_day == 0) { |
|
| 1303 | - $w_day = 7; |
|
| 1304 | - } // Gaffe: le dimanche est zero |
|
| 1305 | - $debut = $jour - $w_day + 1; |
|
| 1301 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1302 | + if ($w_day == 0) { |
|
| 1303 | + $w_day = 7; |
|
| 1304 | + } // Gaffe: le dimanche est zero |
|
| 1305 | + $debut = $jour - $w_day + 1; |
|
| 1306 | 1306 | |
| 1307 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1307 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1308 | 1308 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | function extraire_date($texte): string { |
| 40 | 40 | // format = 2001-08 |
| 41 | 41 | if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
| 42 | - return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 42 | + return $regs[1].'-'.sprintf('%02d', $regs[2]).'-01'; |
|
| 43 | 43 | } |
| 44 | 44 | return ''; |
| 45 | 45 | } |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 72 | 72 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 73 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 73 | + $date = $regs[1].'-00-00'.$regs[3]; |
|
| 74 | 74 | } else { |
| 75 | 75 | if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 76 | 76 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 77 | - $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 77 | + $date = preg_replace('@/@', '-', $regs[1]).'-00'.$regs[3]; |
|
| 78 | 78 | } else { |
| 79 | 79 | $date = date('Y-m-d H:i:s', strtotime($date)); |
| 80 | 80 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | function vider_date($letexte, $verif_format_date = false) { |
| 101 | 101 | if ( |
| 102 | 102 | !$verif_format_date |
| 103 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 103 | + or (in_array(strlen($letexte), [10, 19]) and |
|
| 104 | 104 | preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
| 105 | 105 | ) { |
| 106 | 106 | if (strncmp('0000-00-00', $letexte, 10) == 0) { |
@@ -386,17 +386,17 @@ discard block |
||
| 386 | 386 | if ($decal > 3600 * 24 * 30) { |
| 387 | 387 | $mois = floor($decal / (3600 * 24 * 30)); |
| 388 | 388 | if ($mois < 2) { |
| 389 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 389 | + $delai = "$mois "._T('date_un_mois'); |
|
| 390 | 390 | } else { |
| 391 | - $delai = "$mois " . _T('date_mois'); |
|
| 391 | + $delai = "$mois "._T('date_mois'); |
|
| 392 | 392 | } |
| 393 | 393 | } else { |
| 394 | 394 | if ($decal > 3600 * 24 * 7) { |
| 395 | 395 | $semaines = floor($decal / (3600 * 24 * 7)); |
| 396 | 396 | if ($semaines < 2) { |
| 397 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 397 | + $delai = "$semaines "._T('date_une_semaine'); |
|
| 398 | 398 | } else { |
| 399 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 399 | + $delai = "$semaines "._T('date_semaines'); |
|
| 400 | 400 | } |
| 401 | 401 | } else { |
| 402 | 402 | if ($decal > 3600 * 24) { |
@@ -404,30 +404,30 @@ discard block |
||
| 404 | 404 | if ($jours < 2) { |
| 405 | 405 | return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
| 406 | 406 | } else { |
| 407 | - $delai = "$jours " . _T('date_jours'); |
|
| 407 | + $delai = "$jours "._T('date_jours'); |
|
| 408 | 408 | } |
| 409 | 409 | } else { |
| 410 | 410 | if ($decal >= 3600) { |
| 411 | 411 | $heures = floor($decal / 3600); |
| 412 | 412 | if ($heures < 2) { |
| 413 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 413 | + $delai = "$heures "._T('date_une_heure'); |
|
| 414 | 414 | } else { |
| 415 | - $delai = "$heures " . _T('date_heures'); |
|
| 415 | + $delai = "$heures "._T('date_heures'); |
|
| 416 | 416 | } |
| 417 | 417 | } else { |
| 418 | 418 | if ($decal >= 60) { |
| 419 | 419 | $minutes = floor($decal / 60); |
| 420 | 420 | if ($minutes < 2) { |
| 421 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 421 | + $delai = "$minutes "._T('date_une_minute'); |
|
| 422 | 422 | } else { |
| 423 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 423 | + $delai = "$minutes "._T('date_minutes'); |
|
| 424 | 424 | } |
| 425 | 425 | } else { |
| 426 | 426 | $secondes = ceil($decal); |
| 427 | 427 | if ($secondes < 2) { |
| 428 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 428 | + $delai = "$secondes "._T('date_une_seconde'); |
|
| 429 | 429 | } else { |
| 430 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 430 | + $delai = "$secondes "._T('date_secondes'); |
|
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | } |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | $njour = 0; |
| 521 | 521 | } else { |
| 522 | 522 | $njour = intval($jour); |
| 523 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 523 | + if ($jourth = _T('date_jnum'.$jour)) { |
|
| 524 | 524 | $jour = $jourth; |
| 525 | 525 | } |
| 526 | 526 | } |
@@ -528,10 +528,10 @@ discard block |
||
| 528 | 528 | $mois = intval($mois); |
| 529 | 529 | if ($mois > 0 and $mois < 13) { |
| 530 | 530 | /* Traiter le cas "abbr" pour les noms de mois */ |
| 531 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 532 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 531 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_'.$options['param'] : ''); |
|
| 532 | + $nommois = _T('date_mois_'.$mois.$param); |
|
| 533 | 533 | if ($jour) { |
| 534 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 534 | + $jourmois = _T('date_de_mois_'.$mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 535 | 535 | } else { |
| 536 | 536 | $jourmois = $nommois; |
| 537 | 537 | } |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | if ($annee < 0) { |
| 544 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 544 | + $annee = -$annee.' '._T('date_avant_jc'); |
|
| 545 | 545 | $avjc = true; |
| 546 | 546 | } else { |
| 547 | 547 | $avjc = false; |
@@ -567,11 +567,11 @@ discard block |
||
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | if ($vue == 'saison') { |
| 570 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 570 | + return $saison ? _T('date_saison_'.$saison) : ''; |
|
| 571 | 571 | } else { |
| 572 | 572 | return $saison ? trim(_T( |
| 573 | 573 | 'date_fmt_saison_annee', |
| 574 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 574 | + ['saison' => _T('date_saison_'.$saison), 'annee' => $annee] |
|
| 575 | 575 | )) : ''; |
| 576 | 576 | } |
| 577 | 577 | |
@@ -648,9 +648,9 @@ discard block |
||
| 648 | 648 | } |
| 649 | 649 | $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
| 650 | 650 | $nom = 1 + date('w', $nom); |
| 651 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 651 | + $param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : ''); |
|
| 652 | 652 | |
| 653 | - return _T('date_jour_' . $nom . $param); |
|
| 653 | + return _T('date_jour_'.$nom.$param); |
|
| 654 | 654 | |
| 655 | 655 | case 'mois_annee': |
| 656 | 656 | if ($avjc) { |
@@ -1045,8 +1045,8 @@ discard block |
||
| 1045 | 1045 | |
| 1046 | 1046 | $dtstart = $dtend = $dtabbr = ''; |
| 1047 | 1047 | if (strpos($forme, 'hcal') !== false) { |
| 1048 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1049 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1048 | + $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>"; |
|
| 1049 | + $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>"; |
|
| 1050 | 1050 | $dtabbr = '</abbr>'; |
| 1051 | 1051 | } |
| 1052 | 1052 | |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | } |
| 1095 | 1095 | } else { |
| 1096 | 1096 | if ($dtabbr && $dtstart) { |
| 1097 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1097 | + $s = $dtstart.spip_ucfirst($s).$dtabbr; |
|
| 1098 | 1098 | } else { |
| 1099 | 1099 | $s = spip_ucfirst($s); |
| 1100 | 1100 | } |
@@ -1117,8 +1117,8 @@ discard block |
||
| 1117 | 1117 | $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
| 1118 | 1118 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1119 | 1119 | } |
| 1120 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1121 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1120 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1121 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1122 | 1122 | |
| 1123 | 1123 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1124 | 1124 | } else { |
@@ -1135,8 +1135,8 @@ discard block |
||
| 1135 | 1135 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1139 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1138 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1139 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1140 | 1140 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1141 | 1141 | } |
| 1142 | 1142 | } |
@@ -1240,7 +1240,7 @@ discard block |
||
| 1240 | 1240 | $d = date('Y-m-d'); |
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1243 | + return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2); |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | /** |
@@ -1260,7 +1260,7 @@ discard block |
||
| 1260 | 1260 | $d = date('Y-m-d'); |
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1263 | + return substr($d, 0, 4).substr($d, 5, 2); |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | /** |