Source for file date.inc.php
Documentation is available at date.inc.php
* test case for date functions
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* @author m2mtech <tech@m2m.at>
* @copyright 2007 m2m server software gmbh
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License Version 2
* @version $Id: date.inc.php 99 2007-07-29 14:10:07Z m2mtech $
* @link http://www.ea-geier.at/
require_once('code/date.inc.php');
* test case for date functions
$this->UnitTestCase('Test Date Functions');
* tests checking date format
* - strange but valid format
$this->assertEqual($result, array('year' => '2004', 'month' => '02', 'day' => '29', 'date' => '29.02.2004'));
$this->assertEqual($date, '29.02.2004');
// strange format but valid
$this->assertEqual($result, array('year' => '2004', 'month' => '02', 'day' => '29', 'date' => '29.02.2004'));
$this->assertEqual($date, '29.02.2004');
$this->assertEqual($result, array('year' => '2007', 'month' => '03', 'day' => '01', 'date' => '2007-03-01'));
$this->assertEqual($date, '2007-03-01');
$this->assertEqual($result, array('year' => $year, 'month' => '03', 'day' => '01', 'date' => '01.03.' . $year));
$this->assertEqual($date, '01.03.' . $year);
$this->assertEqual($result, array('year' => $year, 'month' => '03', 'day' => '01', 'date' => $year . '-03-01'));
$this->assertEqual($date, $year . '-03-01');
// smaller than unix & windows capabilities
$this->assertEqual($result, array('year' => '1818', 'month' => '03', 'day' => '01', 'date' => '1818-03-01'));
$this->assertEqual($date, '1818-03-01');
// higher than unix & windows capabilities
$this->assertEqual($result, array('year' => '2218', 'month' => '03', 'day' => '01', 'date' => '2218-03-01'));
$this->assertEqual($date, '2218-03-01');
$this->assertEqual(dateFormat($date), '01.01.2001');
$date = array('year' => 2007, 'month' => 7, 'day' => 3);
$this->assertEqual(dateFormat($date), '03.07.2007');
$this->assertEqual(dateFormat($date, 'YYYY-MM-DD'), '2007-07-03');
$date = array('year' => 2007, 'month' => 2, 'day' => 30);
$this->assertEqual(dateFormat($date), '02.03.2007');
$this->assertEqual(dateFormat($date, 'YYYY-MM-DD'), '2007-03-02');
$date = array('year' => 2004, 'month' => 2, 'day' => 29);
$this->assertEqual(dateFormat($date), '29.02.2004');
$this->assertEqual(dateFormat($date, 'YYYY-MM-DD'), '2004-02-29');
// smaller than unix & windows capabilities
$date = array('year' => 1804, 'month' => 2, 'day' => 23);
$this->assertEqual(dateFormat($date), '23.02.1804');
$this->assertEqual(dateFormat($date, 'YYYY-MM-DD'), '1804-02-23');
// higher than unix & windows capabilities
$date = array('year' => 2804, 'month' => 2, 'day' => 23);
$this->assertEqual(dateFormat($date), '23.02.2804');
$this->assertEqual(dateFormat($date, 'YYYY-MM-DD'), '2804-02-23');
|