@@ -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,22 +96,22 @@ discard block |
||
| 96 | 96 | * - Une chaine vide |
| 97 | 97 | **/ |
| 98 | 98 | function vider_date($letexte, $verif_format_date = false) { |
| 99 | - if ( |
|
| 100 | - !$verif_format_date |
|
| 101 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 102 | - preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 103 | - ) { |
|
| 104 | - if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 105 | - return ''; |
|
| 106 | - } |
|
| 107 | - if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 108 | - return ''; |
|
| 109 | - } |
|
| 110 | - if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 111 | - return ''; |
|
| 112 | - } // eviter le bug GMT-1 |
|
| 113 | - } |
|
| 114 | - return $letexte; |
|
| 99 | + if ( |
|
| 100 | + !$verif_format_date |
|
| 101 | + or (in_array(strlen($letexte), [10,19]) and |
|
| 102 | + preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 103 | + ) { |
|
| 104 | + if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 105 | + return ''; |
|
| 106 | + } |
|
| 107 | + if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 108 | + return ''; |
|
| 109 | + } |
|
| 110 | + if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 111 | + return ''; |
|
| 112 | + } // eviter le bug GMT-1 |
|
| 113 | + } |
|
| 114 | + return $letexte; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | **/ |
| 128 | 128 | function recup_heure($date) { |
| 129 | 129 | |
| 130 | - static $d = [0, 0, 0]; |
|
| 131 | - if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 132 | - return $d; |
|
| 133 | - } |
|
| 130 | + static $d = [0, 0, 0]; |
|
| 131 | + if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 132 | + return $d; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - array_shift($r); |
|
| 135 | + array_shift($r); |
|
| 136 | 136 | |
| 137 | - return $r; |
|
| 137 | + return $r; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -148,12 +148,12 @@ discard block |
||
| 148 | 148 | * @return int heures, sinon 0 |
| 149 | 149 | **/ |
| 150 | 150 | function heures($numdate) { |
| 151 | - $date_array = recup_heure($numdate); |
|
| 152 | - if ($date_array) { |
|
| 153 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 154 | - } |
|
| 151 | + $date_array = recup_heure($numdate); |
|
| 152 | + if ($date_array) { |
|
| 153 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - return $heures; |
|
| 156 | + return $heures; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -167,12 +167,12 @@ discard block |
||
| 167 | 167 | * @return int minutes, sinon 0 |
| 168 | 168 | **/ |
| 169 | 169 | function minutes($numdate) { |
| 170 | - $date_array = recup_heure($numdate); |
|
| 171 | - if ($date_array) { |
|
| 172 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 173 | - } |
|
| 170 | + $date_array = recup_heure($numdate); |
|
| 171 | + if ($date_array) { |
|
| 172 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - return $minutes; |
|
| 175 | + return $minutes; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -186,12 +186,12 @@ discard block |
||
| 186 | 186 | * @return int secondes, sinon 0 |
| 187 | 187 | **/ |
| 188 | 188 | function secondes($numdate) { |
| 189 | - $date_array = recup_heure($numdate); |
|
| 190 | - if ($date_array) { |
|
| 191 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 192 | - } |
|
| 189 | + $date_array = recup_heure($numdate); |
|
| 190 | + if ($date_array) { |
|
| 191 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - return $secondes; |
|
| 194 | + return $secondes; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -210,12 +210,12 @@ discard block |
||
| 210 | 210 | * @return string L'heure formatée dans la langue en cours. |
| 211 | 211 | **/ |
| 212 | 212 | function heures_minutes($numdate, $forme = '') { |
| 213 | - if ($forme != 'abbr') { |
|
| 214 | - return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 215 | - } |
|
| 216 | - else { |
|
| 217 | - return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 218 | - } |
|
| 213 | + if ($forme != 'abbr') { |
|
| 214 | + return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 215 | + } |
|
| 216 | + else { |
|
| 217 | + return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 218 | + } |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -240,56 +240,56 @@ discard block |
||
| 240 | 240 | * @return array [année, mois, jour, heures, minutes, secondes] |
| 241 | 241 | **/ |
| 242 | 242 | function recup_date($numdate, $forcer_jour = true) { |
| 243 | - if (!$numdate) { |
|
| 244 | - return ''; |
|
| 245 | - } |
|
| 246 | - $heures = $minutes = $secondes = 0; |
|
| 247 | - if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 248 | - $jour = $regs[1]; |
|
| 249 | - $mois = $regs[2]; |
|
| 250 | - $annee = $regs[3]; |
|
| 251 | - if ($annee < 90) { |
|
| 252 | - $annee = 2000 + $annee; |
|
| 253 | - } elseif ($annee < 100) { |
|
| 254 | - $annee = 1900 + $annee; |
|
| 255 | - } |
|
| 256 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 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 [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 292 | - } |
|
| 243 | + if (!$numdate) { |
|
| 244 | + return ''; |
|
| 245 | + } |
|
| 246 | + $heures = $minutes = $secondes = 0; |
|
| 247 | + if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 248 | + $jour = $regs[1]; |
|
| 249 | + $mois = $regs[2]; |
|
| 250 | + $annee = $regs[3]; |
|
| 251 | + if ($annee < 90) { |
|
| 252 | + $annee = 2000 + $annee; |
|
| 253 | + } elseif ($annee < 100) { |
|
| 254 | + $annee = 1900 + $annee; |
|
| 255 | + } |
|
| 256 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 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 [$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, ['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, ['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,174 +500,174 @@ discard block |
||
| 500 | 500 | * @return mixed|string |
| 501 | 501 | */ |
| 502 | 502 | function affdate_base($numdate, $vue, $options = []) { |
| 503 | - if (is_string($options)) { |
|
| 504 | - $options = ['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, ['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( |
|
| 570 | - 'date_fmt_saison_annee', |
|
| 571 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 572 | - )) : ''; |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - case 'court': |
|
| 576 | - if ($avjc) { |
|
| 577 | - return $annee; |
|
| 578 | - } |
|
| 579 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 580 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 581 | - return $annee; |
|
| 582 | - } |
|
| 583 | - if ($annee != $a) { |
|
| 584 | - return _T( |
|
| 585 | - 'date_fmt_mois_annee', |
|
| 586 | - ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 587 | - ); |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - return _T( |
|
| 591 | - 'date_fmt_jour_mois', |
|
| 592 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 593 | - ); |
|
| 594 | - |
|
| 595 | - case 'jourcourt': |
|
| 596 | - if ($avjc) { |
|
| 597 | - return $annee; |
|
| 598 | - } |
|
| 599 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 600 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 601 | - return $annee; |
|
| 602 | - } |
|
| 603 | - if ($annee != $a) { |
|
| 604 | - return _T( |
|
| 605 | - 'date_fmt_jour_mois_annee', |
|
| 606 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 607 | - ); |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - return _T( |
|
| 611 | - 'date_fmt_jour_mois', |
|
| 612 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 613 | - ); |
|
| 614 | - |
|
| 615 | - case 'entier': |
|
| 616 | - if ($avjc) { |
|
| 617 | - return $annee; |
|
| 618 | - } |
|
| 619 | - if ($jour) { |
|
| 620 | - return _T( |
|
| 621 | - 'date_fmt_jour_mois_annee', |
|
| 622 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 623 | - ); |
|
| 624 | - } elseif ($mois) { |
|
| 625 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 626 | - } else { |
|
| 627 | - return $annee; |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - case 'nom_mois': |
|
| 631 | - return $nommois; |
|
| 632 | - |
|
| 633 | - case 'mois': |
|
| 634 | - return sprintf('%02s', $mois); |
|
| 635 | - |
|
| 636 | - case 'jour': |
|
| 637 | - return $jour; |
|
| 638 | - |
|
| 639 | - case 'journum': |
|
| 640 | - return $journum; |
|
| 641 | - |
|
| 642 | - case 'nom_jour': |
|
| 643 | - if (!$mois or !$njour) { |
|
| 644 | - return ''; |
|
| 645 | - } |
|
| 646 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 647 | - $nom = 1 + date('w', $nom); |
|
| 648 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 649 | - |
|
| 650 | - return _T('date_jour_' . $nom . $param); |
|
| 651 | - |
|
| 652 | - case 'mois_annee': |
|
| 653 | - if ($avjc) { |
|
| 654 | - return $annee; |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 658 | - |
|
| 659 | - case 'annee': |
|
| 660 | - return $annee; |
|
| 661 | - |
|
| 662 | - // Cas d'une vue non definie : retomber sur le format |
|
| 663 | - // de date propose par http://www.php.net/date |
|
| 664 | - default: |
|
| 665 | - list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 666 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) { |
|
| 667 | - $time = strtotime($numdate); |
|
| 668 | - } |
|
| 669 | - return date($vue, $time); |
|
| 670 | - } |
|
| 503 | + if (is_string($options)) { |
|
| 504 | + $options = ['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, ['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( |
|
| 570 | + 'date_fmt_saison_annee', |
|
| 571 | + ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 572 | + )) : ''; |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + case 'court': |
|
| 576 | + if ($avjc) { |
|
| 577 | + return $annee; |
|
| 578 | + } |
|
| 579 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 580 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 581 | + return $annee; |
|
| 582 | + } |
|
| 583 | + if ($annee != $a) { |
|
| 584 | + return _T( |
|
| 585 | + 'date_fmt_mois_annee', |
|
| 586 | + ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 587 | + ); |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + return _T( |
|
| 591 | + 'date_fmt_jour_mois', |
|
| 592 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 593 | + ); |
|
| 594 | + |
|
| 595 | + case 'jourcourt': |
|
| 596 | + if ($avjc) { |
|
| 597 | + return $annee; |
|
| 598 | + } |
|
| 599 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 600 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 601 | + return $annee; |
|
| 602 | + } |
|
| 603 | + if ($annee != $a) { |
|
| 604 | + return _T( |
|
| 605 | + 'date_fmt_jour_mois_annee', |
|
| 606 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 607 | + ); |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + return _T( |
|
| 611 | + 'date_fmt_jour_mois', |
|
| 612 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 613 | + ); |
|
| 614 | + |
|
| 615 | + case 'entier': |
|
| 616 | + if ($avjc) { |
|
| 617 | + return $annee; |
|
| 618 | + } |
|
| 619 | + if ($jour) { |
|
| 620 | + return _T( |
|
| 621 | + 'date_fmt_jour_mois_annee', |
|
| 622 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 623 | + ); |
|
| 624 | + } elseif ($mois) { |
|
| 625 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 626 | + } else { |
|
| 627 | + return $annee; |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + case 'nom_mois': |
|
| 631 | + return $nommois; |
|
| 632 | + |
|
| 633 | + case 'mois': |
|
| 634 | + return sprintf('%02s', $mois); |
|
| 635 | + |
|
| 636 | + case 'jour': |
|
| 637 | + return $jour; |
|
| 638 | + |
|
| 639 | + case 'journum': |
|
| 640 | + return $journum; |
|
| 641 | + |
|
| 642 | + case 'nom_jour': |
|
| 643 | + if (!$mois or !$njour) { |
|
| 644 | + return ''; |
|
| 645 | + } |
|
| 646 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 647 | + $nom = 1 + date('w', $nom); |
|
| 648 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 649 | + |
|
| 650 | + return _T('date_jour_' . $nom . $param); |
|
| 651 | + |
|
| 652 | + case 'mois_annee': |
|
| 653 | + if ($avjc) { |
|
| 654 | + return $annee; |
|
| 655 | + } |
|
| 656 | + |
|
| 657 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 658 | + |
|
| 659 | + case 'annee': |
|
| 660 | + return $annee; |
|
| 661 | + |
|
| 662 | + // Cas d'une vue non definie : retomber sur le format |
|
| 663 | + // de date propose par http://www.php.net/date |
|
| 664 | + default: |
|
| 665 | + list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 666 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) { |
|
| 667 | + $time = strtotime($numdate); |
|
| 668 | + } |
|
| 669 | + return date($vue, $time); |
|
| 670 | + } |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | |
@@ -694,11 +694,11 @@ discard block |
||
| 694 | 694 | * Nom du jour |
| 695 | 695 | **/ |
| 696 | 696 | function nom_jour($numdate, $forme = '') { |
| 697 | - if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 698 | - $forme = ''; |
|
| 699 | - } |
|
| 697 | + if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 698 | + $forme = ''; |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | - return affdate_base($numdate, 'nom_jour', $forme); |
|
| 701 | + return affdate_base($numdate, 'nom_jour', $forme); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | /** |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | * Numéro du jour |
| 721 | 721 | **/ |
| 722 | 722 | function jour($numdate) { |
| 723 | - return affdate_base($numdate, 'jour'); |
|
| 723 | + return affdate_base($numdate, 'jour'); |
|
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | /** |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | * Numéro du jour |
| 739 | 739 | **/ |
| 740 | 740 | function journum($numdate) { |
| 741 | - return affdate_base($numdate, 'journum'); |
|
| 741 | + return affdate_base($numdate, 'journum'); |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | /** |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | * Numéro du mois (sur 2 chiffres) |
| 757 | 757 | **/ |
| 758 | 758 | function mois($numdate) { |
| 759 | - return affdate_base($numdate, 'mois'); |
|
| 759 | + return affdate_base($numdate, 'mois'); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | /** |
@@ -780,11 +780,11 @@ discard block |
||
| 780 | 780 | * Nom du mois |
| 781 | 781 | **/ |
| 782 | 782 | function nom_mois($numdate, $forme = '') { |
| 783 | - if (!($forme == 'abbr')) { |
|
| 784 | - $forme = ''; |
|
| 785 | - } |
|
| 783 | + if (!($forme == 'abbr')) { |
|
| 784 | + $forme = ''; |
|
| 785 | + } |
|
| 786 | 786 | |
| 787 | - return affdate_base($numdate, 'nom_mois', $forme); |
|
| 787 | + return affdate_base($numdate, 'nom_mois', $forme); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | /** |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | * Année (sur 4 chiffres) |
| 803 | 803 | **/ |
| 804 | 804 | function annee($numdate) { |
| 805 | - return affdate_base($numdate, 'annee'); |
|
| 805 | + return affdate_base($numdate, 'annee'); |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | |
@@ -832,11 +832,11 @@ discard block |
||
| 832 | 832 | * La date formatée |
| 833 | 833 | **/ |
| 834 | 834 | function saison($numdate, $hemisphere = 'nord') { |
| 835 | - if ($hemisphere != 'sud') { |
|
| 836 | - $hemisphere = 'nord'; |
|
| 837 | - } |
|
| 835 | + if ($hemisphere != 'sud') { |
|
| 836 | + $hemisphere = 'nord'; |
|
| 837 | + } |
|
| 838 | 838 | |
| 839 | - return affdate_base($numdate, 'saison', $hemisphere); |
|
| 839 | + return affdate_base($numdate, 'saison', $hemisphere); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | |
@@ -865,11 +865,11 @@ discard block |
||
| 865 | 865 | * La date formatée |
| 866 | 866 | **/ |
| 867 | 867 | function saison_annee($numdate, $hemisphere = 'nord') { |
| 868 | - if ($hemisphere != 'sud') { |
|
| 869 | - $hemisphere = 'nord'; |
|
| 870 | - } |
|
| 868 | + if ($hemisphere != 'sud') { |
|
| 869 | + $hemisphere = 'nord'; |
|
| 870 | + } |
|
| 871 | 871 | |
| 872 | - return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 872 | + return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | /** |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | * La date formatée |
| 898 | 898 | **/ |
| 899 | 899 | function affdate($numdate, $format = 'entier') { |
| 900 | - return affdate_base($numdate, $format); |
|
| 900 | + return affdate_base($numdate, $format); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | * La date formatée |
| 925 | 925 | **/ |
| 926 | 926 | function affdate_court($numdate, $annee_courante = null) { |
| 927 | - return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 927 | + return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | * La date formatée |
| 952 | 952 | **/ |
| 953 | 953 | function affdate_jourcourt($numdate, $annee_courante = null) { |
| 954 | - return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 954 | + return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | /** |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | * La date formatée |
| 970 | 970 | **/ |
| 971 | 971 | function affdate_mois_annee($numdate) { |
| 972 | - return affdate_base($numdate, 'mois_annee'); |
|
| 972 | + return affdate_base($numdate, 'mois_annee'); |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | /** |
@@ -987,16 +987,16 @@ discard block |
||
| 987 | 987 | * La date formatée |
| 988 | 988 | **/ |
| 989 | 989 | function affdate_heure($numdate) { |
| 990 | - $date_array = recup_date($numdate); |
|
| 991 | - if (!$date_array) { |
|
| 992 | - return; |
|
| 993 | - } |
|
| 994 | - list($annee, $mois, $jour, $heures, $minutes, $sec) = $date_array; |
|
| 995 | - |
|
| 996 | - return _T('date_fmt_jour_heure', [ |
|
| 997 | - 'jour' => affdate($numdate), |
|
| 998 | - 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 999 | - ]); |
|
| 990 | + $date_array = recup_date($numdate); |
|
| 991 | + if (!$date_array) { |
|
| 992 | + return; |
|
| 993 | + } |
|
| 994 | + list($annee, $mois, $jour, $heures, $minutes, $sec) = $date_array; |
|
| 995 | + |
|
| 996 | + return _T('date_fmt_jour_heure', [ |
|
| 997 | + 'jour' => affdate($numdate), |
|
| 998 | + 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 999 | + ]); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1028,117 +1028,117 @@ discard block |
||
| 1028 | 1028 | * Texte de la date |
| 1029 | 1029 | */ |
| 1030 | 1030 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = '') { |
| 1031 | - $abbr = $jour = ''; |
|
| 1032 | - $affdate = 'affdate_jourcourt'; |
|
| 1033 | - if (strpos($forme, 'abbr') !== false) { |
|
| 1034 | - $abbr = 'abbr'; |
|
| 1035 | - } |
|
| 1036 | - if (strpos($forme, 'annee') !== false) { |
|
| 1037 | - $affdate = 'affdate'; |
|
| 1038 | - } |
|
| 1039 | - if (strpos($forme, 'jour') !== false) { |
|
| 1040 | - $jour = 'jour'; |
|
| 1041 | - } |
|
| 1042 | - |
|
| 1043 | - $dtstart = $dtend = $dtabbr = ''; |
|
| 1044 | - if (strpos($forme, 'hcal') !== false) { |
|
| 1045 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1046 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1047 | - $dtabbr = '</abbr>'; |
|
| 1048 | - } |
|
| 1049 | - |
|
| 1050 | - $date_debut = strtotime($date_debut); |
|
| 1051 | - $date_fin = strtotime($date_fin); |
|
| 1052 | - $d = date('Y-m-d', $date_debut); |
|
| 1053 | - $f = date('Y-m-d', $date_fin); |
|
| 1054 | - $h = ($horaire === 'oui' or $horaire === true); |
|
| 1055 | - $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1056 | - $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1057 | - |
|
| 1058 | - if ($d == $f) { // meme jour |
|
| 1059 | - $nomjour = nom_jour($d, $abbr); |
|
| 1060 | - $s = $affdate($d); |
|
| 1061 | - $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1062 | - if ($h) { |
|
| 1063 | - if ($hd == $hf) { |
|
| 1064 | - // Lundi 20 fevrier a 18h25 |
|
| 1065 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1066 | - $s = "$dtstart$s$dtabbr"; |
|
| 1067 | - } else { |
|
| 1068 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1069 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1070 | - $s = _T( |
|
| 1071 | - 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1072 | - [ |
|
| 1073 | - 'jour' => spip_ucfirst($s), |
|
| 1074 | - 'heure_debut' => $hd, |
|
| 1075 | - 'heure_fin' => $hf, |
|
| 1076 | - 'dtstart' => $dtstart, |
|
| 1077 | - 'dtend' => $dtend, |
|
| 1078 | - 'dtabbr' => $dtabbr |
|
| 1079 | - ], |
|
| 1080 | - [ |
|
| 1081 | - 'sanitize' => false |
|
| 1082 | - ] |
|
| 1083 | - ); |
|
| 1084 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1085 | - else { |
|
| 1086 | - $s = spip_ucfirst(_T( |
|
| 1087 | - 'date_fmt_jour_heure_debut_fin', |
|
| 1088 | - ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1089 | - )); |
|
| 1090 | - } |
|
| 1091 | - } |
|
| 1092 | - } else { |
|
| 1093 | - if ($dtabbr && $dtstart) { |
|
| 1094 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1095 | - } else { |
|
| 1096 | - $s = spip_ucfirst($s); |
|
| 1097 | - } |
|
| 1098 | - } |
|
| 1099 | - } else { |
|
| 1100 | - if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1101 | - if (!$h) { |
|
| 1102 | - $date_debut = jour($d); |
|
| 1103 | - } else { |
|
| 1104 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1105 | - } |
|
| 1106 | - $date_fin = $affdate($f); |
|
| 1107 | - if ($jour) { |
|
| 1108 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1109 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1110 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1111 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1112 | - } |
|
| 1113 | - if ($h) { |
|
| 1114 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1115 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1116 | - } |
|
| 1117 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1118 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1119 | - |
|
| 1120 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1121 | - } else { |
|
| 1122 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1123 | - $date_fin = $affdate($f); |
|
| 1124 | - if ($jour) { |
|
| 1125 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1126 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1127 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1128 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1129 | - } |
|
| 1130 | - if ($h) { |
|
| 1131 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1132 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1133 | - } |
|
| 1134 | - |
|
| 1135 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1136 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1137 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1138 | - } |
|
| 1139 | - } |
|
| 1140 | - |
|
| 1141 | - return $s; |
|
| 1031 | + $abbr = $jour = ''; |
|
| 1032 | + $affdate = 'affdate_jourcourt'; |
|
| 1033 | + if (strpos($forme, 'abbr') !== false) { |
|
| 1034 | + $abbr = 'abbr'; |
|
| 1035 | + } |
|
| 1036 | + if (strpos($forme, 'annee') !== false) { |
|
| 1037 | + $affdate = 'affdate'; |
|
| 1038 | + } |
|
| 1039 | + if (strpos($forme, 'jour') !== false) { |
|
| 1040 | + $jour = 'jour'; |
|
| 1041 | + } |
|
| 1042 | + |
|
| 1043 | + $dtstart = $dtend = $dtabbr = ''; |
|
| 1044 | + if (strpos($forme, 'hcal') !== false) { |
|
| 1045 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1046 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1047 | + $dtabbr = '</abbr>'; |
|
| 1048 | + } |
|
| 1049 | + |
|
| 1050 | + $date_debut = strtotime($date_debut); |
|
| 1051 | + $date_fin = strtotime($date_fin); |
|
| 1052 | + $d = date('Y-m-d', $date_debut); |
|
| 1053 | + $f = date('Y-m-d', $date_fin); |
|
| 1054 | + $h = ($horaire === 'oui' or $horaire === true); |
|
| 1055 | + $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1056 | + $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1057 | + |
|
| 1058 | + if ($d == $f) { // meme jour |
|
| 1059 | + $nomjour = nom_jour($d, $abbr); |
|
| 1060 | + $s = $affdate($d); |
|
| 1061 | + $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1062 | + if ($h) { |
|
| 1063 | + if ($hd == $hf) { |
|
| 1064 | + // Lundi 20 fevrier a 18h25 |
|
| 1065 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1066 | + $s = "$dtstart$s$dtabbr"; |
|
| 1067 | + } else { |
|
| 1068 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1069 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1070 | + $s = _T( |
|
| 1071 | + 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1072 | + [ |
|
| 1073 | + 'jour' => spip_ucfirst($s), |
|
| 1074 | + 'heure_debut' => $hd, |
|
| 1075 | + 'heure_fin' => $hf, |
|
| 1076 | + 'dtstart' => $dtstart, |
|
| 1077 | + 'dtend' => $dtend, |
|
| 1078 | + 'dtabbr' => $dtabbr |
|
| 1079 | + ], |
|
| 1080 | + [ |
|
| 1081 | + 'sanitize' => false |
|
| 1082 | + ] |
|
| 1083 | + ); |
|
| 1084 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1085 | + else { |
|
| 1086 | + $s = spip_ucfirst(_T( |
|
| 1087 | + 'date_fmt_jour_heure_debut_fin', |
|
| 1088 | + ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1089 | + )); |
|
| 1090 | + } |
|
| 1091 | + } |
|
| 1092 | + } else { |
|
| 1093 | + if ($dtabbr && $dtstart) { |
|
| 1094 | + $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1095 | + } else { |
|
| 1096 | + $s = spip_ucfirst($s); |
|
| 1097 | + } |
|
| 1098 | + } |
|
| 1099 | + } else { |
|
| 1100 | + if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1101 | + if (!$h) { |
|
| 1102 | + $date_debut = jour($d); |
|
| 1103 | + } else { |
|
| 1104 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1105 | + } |
|
| 1106 | + $date_fin = $affdate($f); |
|
| 1107 | + if ($jour) { |
|
| 1108 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1109 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1110 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1111 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1112 | + } |
|
| 1113 | + if ($h) { |
|
| 1114 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1115 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1116 | + } |
|
| 1117 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1118 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1119 | + |
|
| 1120 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1121 | + } else { |
|
| 1122 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1123 | + $date_fin = $affdate($f); |
|
| 1124 | + if ($jour) { |
|
| 1125 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1126 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1127 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1128 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1129 | + } |
|
| 1130 | + if ($h) { |
|
| 1131 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1132 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1133 | + } |
|
| 1134 | + |
|
| 1135 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1136 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1137 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1138 | + } |
|
| 1139 | + } |
|
| 1140 | + |
|
| 1141 | + return $s; |
|
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | /** |
@@ -1159,10 +1159,10 @@ discard block |
||
| 1159 | 1159 | * Date au format ical |
| 1160 | 1160 | **/ |
| 1161 | 1161 | function date_ical($date, $addminutes = 0) { |
| 1162 | - list($heures, $minutes, $secondes) = recup_heure($date); |
|
| 1163 | - list($annee, $mois, $jour) = recup_date($date); |
|
| 1162 | + list($heures, $minutes, $secondes) = recup_heure($date); |
|
| 1163 | + list($annee, $mois, $jour) = recup_date($date); |
|
| 1164 | 1164 | |
| 1165 | - return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1165 | + return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | |
@@ -1186,11 +1186,11 @@ discard block |
||
| 1186 | 1186 | * La date formatée |
| 1187 | 1187 | **/ |
| 1188 | 1188 | function date_iso($date_heure) { |
| 1189 | - list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1190 | - list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1191 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1189 | + list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1190 | + list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1191 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1192 | 1192 | |
| 1193 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1193 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | /** |
@@ -1213,11 +1213,11 @@ discard block |
||
| 1213 | 1213 | * La date formatée |
| 1214 | 1214 | **/ |
| 1215 | 1215 | function date_822($date_heure) { |
| 1216 | - list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1217 | - list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1218 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1216 | + list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1217 | + list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1218 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1219 | 1219 | |
| 1220 | - return date('r', $time); |
|
| 1220 | + return date('r', $time); |
|
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | /** |
@@ -1233,11 +1233,11 @@ discard block |
||
| 1233 | 1233 | * Date au format `Ymd` |
| 1234 | 1234 | **/ |
| 1235 | 1235 | function date_anneemoisjour($d) { |
| 1236 | - if (!$d) { |
|
| 1237 | - $d = date('Y-m-d'); |
|
| 1238 | - } |
|
| 1236 | + if (!$d) { |
|
| 1237 | + $d = date('Y-m-d'); |
|
| 1238 | + } |
|
| 1239 | 1239 | |
| 1240 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1240 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | /** |
@@ -1253,11 +1253,11 @@ discard block |
||
| 1253 | 1253 | * Date au format `Ym` |
| 1254 | 1254 | **/ |
| 1255 | 1255 | function date_anneemois($d) { |
| 1256 | - if (!$d) { |
|
| 1257 | - $d = date('Y-m-d'); |
|
| 1258 | - } |
|
| 1256 | + if (!$d) { |
|
| 1257 | + $d = date('Y-m-d'); |
|
| 1258 | + } |
|
| 1259 | 1259 | |
| 1260 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1260 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | /** |
@@ -1273,13 +1273,13 @@ discard block |
||
| 1273 | 1273 | * Date au lundi de la même semaine au format `Ymd` |
| 1274 | 1274 | **/ |
| 1275 | 1275 | function date_debut_semaine($annee, $mois, $jour) { |
| 1276 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1277 | - if ($w_day == 0) { |
|
| 1278 | - $w_day = 7; |
|
| 1279 | - } // Gaffe: le dimanche est zero |
|
| 1280 | - $debut = $jour - $w_day + 1; |
|
| 1276 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1277 | + if ($w_day == 0) { |
|
| 1278 | + $w_day = 7; |
|
| 1279 | + } // Gaffe: le dimanche est zero |
|
| 1280 | + $debut = $jour - $w_day + 1; |
|
| 1281 | 1281 | |
| 1282 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1282 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1283 | 1283 | } |
| 1284 | 1284 | |
| 1285 | 1285 | /** |
@@ -1295,11 +1295,11 @@ discard block |
||
| 1295 | 1295 | * Date au dimanche de la même semaine au format `Ymd` |
| 1296 | 1296 | **/ |
| 1297 | 1297 | function date_fin_semaine($annee, $mois, $jour) { |
| 1298 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1299 | - if ($w_day == 0) { |
|
| 1300 | - $w_day = 7; |
|
| 1301 | - } // Gaffe: le dimanche est zero |
|
| 1302 | - $debut = $jour - $w_day + 1; |
|
| 1298 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1299 | + if ($w_day == 0) { |
|
| 1300 | + $w_day = 7; |
|
| 1301 | + } // Gaffe: le dimanche est zero |
|
| 1302 | + $debut = $jour - $w_day + 1; |
|
| 1303 | 1303 | |
| 1304 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1304 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1305 | 1305 | } |