Projet

Général

Profil

Révision db9ffd17

Ajouté par Assos Assos il y a presque 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/date/date_api/date_api.module
459 459
    if (!$true && $granularity) {
460 460
      foreach ((array) $granularity as $part) {
461 461
        if (!$this->hasGranularity($part) && in_array($part, array('second', 'minute', 'hour', 'day', 'month', 'year'))) {
462
          $this->errors[$part] = t("The $part is missing.");
462
          switch ($part) {
463
            case 'second':
464
              $this->errors[$part] = t('The second is missing.');
465
              break;
466
            case 'minute':
467
              $this->errors[$part] = t('The minute is missing.');
468
              break;
469
            case 'hour':
470
              $this->errors[$part] = t('The hour is missing.');
471
              break;
472
            case 'day':
473
              $this->errors[$part] = t('The day is missing.');
474
              break;
475
            case 'month':
476
              $this->errors[$part] = t('The month is missing.');
477
              break;
478
            case 'year':
479
              $this->errors[$part] = t('The year is missing.');
480
              break;
481
          }
463 482
        }
464 483
      }
465 484
    }
......
1727 1746
 *   The current time as a date object.
1728 1747
 */
1729 1748
function date_now($timezone = NULL, $reset = FALSE) {
1730
  $now = &drupal_static(__FUNCTION__);
1749
  if ($reset) {
1750
    drupal_static_reset(__FUNCTION__ . $timezone);
1751
  }
1752

  
1753
  $now = &drupal_static(__FUNCTION__ . $timezone);
1731 1754

  
1732
  if (!isset($now) || $reset) {
1755
  if (!isset($now)) {
1733 1756
    $now = new DateObject('now', $timezone);
1734 1757
  }
1735 1758

  
1736
  return $now;
1759
  // Avoid unexpected manipulation of cached $now object
1760
  // by subsequent code execution
1761
  // @see https://drupal.org/node/2261395
1762
  $clone = clone $now;
1763
  return $clone;
1737 1764
}
1765

  
1738 1766
/**
1739 1767
 * Determines if a timezone string is valid.
1740 1768
 *
......
2357 2385
}
2358 2386

  
2359 2387
/**
2360
 * Function to figure out which db timezone applies to a date and select it.
2388
 * Function to figure out which db timezone applies to a date.
2361 2389
 *
2362 2390
 * @param string $handling
2363 2391
 *   The timezone handling.
2364 2392
 * @param string $timezone
2365
 *   (optional) A timezone string. Defaults to an empty string.
2393
 *   (optional) When $handling is 'date', date_get_timezone_db() returns this
2394
 *   value.
2366 2395
 *
2367 2396
 * @return string
2368 2397
 *   The timezone string.
2369 2398
 */
2370
function date_get_timezone_db($handling, $timezone = '') {
2399
function date_get_timezone_db($handling, $timezone = NULL) {
2371 2400
  switch ($handling) {
2372
    case 'none':
2373
      $timezone = date_default_timezone();
2401
    case ('utc'):
2402
    case ('site'):
2403
    case ('user'):
2404
      // These handling modes all convert to UTC before storing in the DB.
2405
      $timezone = 'UTC';
2406
      break;
2407
    case ('date'):
2408
      if ($timezone == NULL) {
2409
        // This shouldn't happen, since it's meaning is undefined. But we need
2410
        // to fall back to *something* that's a legal timezone.
2411
        $timezone = date_default_timezone();
2412
      }
2374 2413
      break;
2414
    case ('none'):
2375 2415
    default:
2376
      $timezone = 'UTC';
2416
      $timezone = date_default_timezone();
2377 2417
      break;
2378 2418
  }
2379
  return $timezone > '' ? $timezone : 'UTC';
2419
  return $timezone;
2380 2420
}
2381 2421

  
2382 2422
/**

Formats disponibles : Unified diff