1Handler::Delta(3)     User Contributed Perl Documentation    Handler::Delta(3)
2
3
4

NAME

6       Date::Handler::Delta - Time lapse object
7

SYNOPSIS

9         use Date::Handler::Delta;
10
11          my $delta = new Date::Handler::Delta([3,1,10,2,5,5]);
12          my $delta = new Date::Handler::Delta({
13                                                       years => 3,
14                                                       months => 1,
15                                                       days => 10,
16                                                       hours => 2,
17                                                       minutes => 5,
18                                                       seconds => 5,
19                                               });
20
21          $delta->new                          (More information in perldoc Date::Handler::Delta)
22          $delta->Months()                     Number of months in delta
23          $delta->Seconds()                    Number of seconds in delta
24          $delta->AsScalar()                   "%d months and %d seconds"
25          $delta->AsNumber()                   "%d-%d-%d"
26          $delta->AsArray()                    [y,m,ss]
27          $delta->AsHash()                     { months => m, seconds => ss }
28
29          $date + $delta = Date::Handler
30          $date - $delta = Date::Handler
31          $date - $date2 = Date::Handler::Delta
32          $date + n = (+n seconds)
33          $date - n = (-n seconds)
34
35          $delta + $delta = Date::Handler::Delta
36          $delta - $delta = Date::Handler::Delta
37          $delta * n = Date::Handler::Delta
38          $delta / n = Date::Handler::Delta
39          $delta + n = (+n seconds)
40          $delta - n = (-n seconds)
41

DESCRIPTION

43       Date::Handler::Delta is an object that represents a lapse of time. It's
44       internal representation of a time lapse if reduced to months and
45       seconds. A Date::Handler::Delta object is always relative to a
46       Date::Handler object, it's calculation methods become active when the
47       delta is applied to a date.
48

IMPLEMENTATION

50       Implementation details
51
52   Creating a Date::Handler::Delta object
53       The new() constructor receives only one argument as an array reference
54       or hash reference:
55
56               my $delta = Date::Handler::Delta->new([1,3,5,0,0]);
57               my $delta = Date::Handler::Delta->new({
58                                                       years => 1,
59                                                       months => 3,
60                                                       days => 5,
61                                                       minutes= > 0,
62                                                       seconds => 0,
63                                               });
64
65       •  As array reference, the order if years, months, days, minutes
66          seconds
67
68       •  As hash reference, the keys are years, months, days, minutes,
69          seconds.
70
71   Accessors
72       You can access the data inside the object using any of the provided
73       methods.  These methods are detailed in the SYNOPSIS up above.
74
75       Since Date::Handler uses operator overloading, you can 'apply' a Delta
76       object on an absolute date simply by using built-in operators.
77
78       Example:
79
80               #A Delta of 1 year.
81               my $delta = new Date::Handler::Delta([1,0,0,0,0,0]);
82
83               my $date = new Date::Handler({ date => time } );
84
85               #$newdate is now one year in the furure.
86               my $newdate = $date+$delta;
87
88   Operator overload special cases
89       The Date::Handler overloaded operator have special cases. Refer to the
90       SYNOPSIS to get a description of each overloaded operator's behaviour.
91
92       One special case of the overload is when adding an integer 'n' to a
93       Date::Handler's reference. This is treated as if 'n' was in seconds.
94       Same thing for substraction.
95
96       Example Uses of the overload:
97
98               my $date = new Date::Handler({ date =>
99                                               {
100                                                       year => 2001,
101                                                       month => 5,
102                                                       day => 14,
103                                                       hour => 5,
104                                                       min => 0,
105                                                       sec => 0,
106                                               }});
107               #Quoted string overload
108               print "Current date is $date\n";
109
110               my $delta = new Date::Handler::Delta({ days => 5, });
111
112               #'+' overload, now, $date is 5 days in the future.
113               $date += $delta;
114
115               #Small clock. Not too accurate, but still ;)
116               while(1)
117               {
118                       #Add one second to the date. (same as $date + 1)
119                       $date++;
120                       print "$date\n";
121                       sleep(1);
122               }
123

BUGS (known)

125       Deltas going after 2038 are not handled by this module yet. (POSIX)
126
127       Deltas before 1902 are not handled by this module. (POSIX)
128
129       If you find bugs with this module, do not hesitate to contact the
130       author.  Your comments and rants are welcomed :)
131

TODO

133       Refine reduction to simplest expression of the delta.
134
136       Copyright(c) 2001 Benoit Beausejour <bbeausej@pobox.com>
137
138       All rights reserved. This program is free software; you can
139       redistribute it and/or modify it under the same terms as Perl itself.
140
141       Portions Copyright (c) Philippe M. Chiasson <gozer@cpan.org>
142
143       Portions Copyright (c) Szabó, Balázs <dlux@kapu.hu>
144
145       Portions Copyright (c) Larry Rosler
146

AUTHOR

148       Benoit Beausejour <bbeausej@pobox.com>
149

SEE ALSO

151       Date::Handler(1).  Date::Handler::Range(1).  Class::Date(1).
152       Time::Object(1).  Date::Calc(1).  perl(1).
153

POD ERRORS

155       Hey! The above document had some coding errors, which are explained
156       below:
157
158       Around line 459:
159           Non-ASCII character seen before =encoding in 'Szabó,'. Assuming
160           CP1252
161
162
163
164perl v5.34.0                      2021-07-22                 Handler::Delta(3)
Impressum