Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

DateComparator.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 1.43 KiB


 01  <?php
 02   
 03  /*
 04   * This file is part of the Symfony package.
 05   *
 06   * (c) Fabien Potencier <fabien@symfony.com>
 07   *
 08   * For the full copyright and license information, please view the LICENSE
 09   * file that was distributed with this source code.
 10   */
 11   
 12  namespace Symfony\Component\Finder\Comparator;
 13   
 14  /**
 15   * DateCompare compiles date comparisons.
 16   *
 17   * @author Fabien Potencier <fabien@symfony.com>
 18   */
 19  class DateComparator extends Comparator
 20  {
 21      /**
 22       * Constructor.
 23       *
 24       * @param string $test A comparison string
 25       *
 26       * @throws \InvalidArgumentException If the test is not understood
 27       */
 28      public function __construct($test)
 29      {
 30          if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
 31              throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
 32          }
 33   
 34          try {
 35              $date = new \DateTime($matches[2]);
 36              $target = $date->format('U');
 37          } catch (\Exception $e) {
 38              throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
 39          }
 40   
 41          $operator = isset($matches[1]) ? $matches[1] : '==';
 42          if ('since' === $operator || 'after' === $operator) {
 43              $operator = '>';
 44          }
 45   
 46          if ('until' === $operator || 'before' === $operator) {
 47              $operator = '<';
 48          }
 49   
 50          $this->setOperator($operator);
 51          $this->setTarget($target);
 52      }
 53  }
 54