| 1 |
lars |
1 |
<?php
|
|
|
2 |
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
|
|
3 |
//
|
|
|
4 |
// +----------------------------------------------------------------------+
|
|
|
5 |
// | Copyright (c) 1997-2005 Leandro Lucarella |
|
|
|
6 |
// +----------------------------------------------------------------------+
|
|
|
7 |
// | This source file is subject to the New BSD license, That is bundled |
|
|
|
8 |
// | with this package in the file LICENSE, and is available through |
|
|
|
9 |
// | the world-wide-web at |
|
|
|
10 |
// | http://www.opensource.org/licenses/bsd-license.php |
|
|
|
11 |
// | If you did not receive a copy of the new BSDlicense and are unable |
|
|
|
12 |
// | to obtain it through the world-wide-web, please send a note to |
|
|
|
13 |
// | pear-dev@lists.php.net so we can mail you a copy immediately. |
|
|
|
14 |
// +----------------------------------------------------------------------+
|
|
|
15 |
// | Author: Leandro Lucarella <llucax@php.net> |
|
|
|
16 |
// +----------------------------------------------------------------------+
|
|
|
17 |
//
|
|
|
18 |
// $Id: test_date_methods_span.php,v 1.2 2005/11/15 00:16:40 pajoye Exp $
|
|
|
19 |
//
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
require_once 'Date.php';
|
|
|
23 |
require_once 'Date/Span.php';
|
|
|
24 |
|
|
|
25 |
$date = new Date();
|
|
|
26 |
$tmp = new Date($date);
|
|
|
27 |
|
|
|
28 |
printf("Actual date: %s\n", $date->getDate(DATE_FORMAT_ISO));
|
|
|
29 |
|
|
|
30 |
$tmp->copy($date);
|
|
|
31 |
$tmp->subtractSpan(new Date_Span('0:00:00:05'));
|
|
|
32 |
printf("Subtracting 5 seconds: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
|
|
|
33 |
|
|
|
34 |
$tmp->copy($date);
|
|
|
35 |
$tmp->subtractSpan(new Date_Span('0:00:20:00'));
|
|
|
36 |
printf("Subtracting 20 minutes: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
|
|
|
37 |
|
|
|
38 |
$tmp->copy($date);
|
|
|
39 |
$tmp->subtractSpan(new Date_Span('0:10:00:00'));
|
|
|
40 |
printf("Subtracting 10 hours: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
|
|
|
41 |
|
|
|
42 |
$tmp->copy($date);
|
|
|
43 |
$tmp->subtractSpan(new Date_Span('3:00:00:00'));
|
|
|
44 |
printf("Subtracting 3 days: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
|
|
|
45 |
|
|
|
46 |
$tmp->copy($date);
|
|
|
47 |
$tmp->subtractSpan(new Date_Span('3:10:20:05'));
|
|
|
48 |
printf("Subtracting 3 days, 10 hours, 20 minutes and 5 seconds: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
|
|
|
49 |
|
|
|
50 |
$tmp->copy($date);
|
|
|
51 |
$tmp->addSpan(new Date_Span('0:00:00:05'));
|
|
|
52 |
printf("Adding 5 seconds: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
|
|
|
53 |
|
|
|
54 |
$tmp->copy($date);
|
|
|
55 |
$tmp->addSpan(new Date_Span('0:00:20:00'));
|
|
|
56 |
printf("Adding 20 minutes: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
|
|
|
57 |
|
|
|
58 |
$tmp->copy($date);
|
|
|
59 |
$tmp->addSpan(new Date_Span('0:10:00:00'));
|
|
|
60 |
printf("Adding 10 hours: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
|
|
|
61 |
|
|
|
62 |
$tmp->copy($date);
|
|
|
63 |
$tmp->addSpan(new Date_Span('3:00:00:00'));
|
|
|
64 |
printf("Adding 3 days: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
|
|
|
65 |
|
|
|
66 |
$tmp->copy($date);
|
|
|
67 |
$tmp->addSpan(new Date_Span('3:10:20:05'));
|
|
|
68 |
printf("Adding 3 days, 10 hours, 20 minutes and 5 seconds: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
|
|
|
69 |
|
|
|
70 |
?>
|