1Date::Manip::Obj(3)   User Contributed Perl Documentation  Date::Manip::Obj(3)
2
3
4

NAME

6       Date::Manip::Obj - Base class for Date::Manip objects
7

SYNOPSIS

9       The Date::Manip::Obj class is the base class used for the following
10       Date::Manip classes:
11
12       Date::Manip::Base
13       Date::Manip::TZ
14       Date::Manip::Date
15       Date::Manip::Delta
16       Date::Manip::Recur
17
18       This module is not intended to be called directly and performs no
19       useful function by itself. Instead, use the various derived classes
20       which inherit from it.
21

DESCRIPTION

23       This module contains a set of methods used by all Date::Manip classes
24       listed above.
25
26       You should be familiar with the Date::Manip::Objects and
27       Date::Manip::Config documentation.
28
29       In the method descriptions below, Date::Manip::Date objects will
30       usually be used as examples, but (unless otherwise stated), all of the
31       classes listed above have the same methods, and work in the same
32       fashion.
33

METHODS FOR CREATING OBJECTS

35       In the examples below, any $date ($date, $date1, $date2, ...) variable
36       is a Date::Manip::Date object. Similarly, $delta, $recur, $tz, and
37       $base refer to objects in the appropriate class.
38
39       Any $obj variable refers to an object in any of the classes.
40
41       new There are two ways to use the new method. They are:
42
43              $obj2  = new CLASS ($obj1,$string,[@parse_opts,]\@opts);
44              $obj2  = $obj1->new($string,[@parse_opts,]\@opts)
45
46           In both cases, all arguments are optional.
47
48           Here, CLASS is the class of the new object. For example:
49
50              $date  = new Date::Manip::Date;
51              $delta = new Date::Manip::Delta;
52
53           if $obj1 is available, the new object will share as much
54           information from the old object as possible. The class of the new
55           object may be derived from the old object as well.
56
57           For example, if you call either of these:
58
59              $date2 = new Date::Manip::Date $date1;
60              $date2 = $date1->new();
61
62           the new date object will use the same embedded Date::Manip::TZ
63           object. In the second case, the class of the new object ($date2) is
64           Date::Manip::Date because that is the class of the original object.
65
66           When specifying CLASS and including an old object, objects do not
67           need to be of the same class.  For example, the following are all
68           valid:
69
70              $date = new Date::Manip::Date $delta;
71              $date = new Date::Manip::Date $tz;
72
73           You can even do:
74
75              $date = new Date::Manip::Date $base;
76
77           but this will have to create a completely new Date::Manip::TZ
78           object, which means that optimal performance may not be achieved if
79           a Date::Manip::TZ object already exists.
80
81           There are two special cases. Either of the following will create a
82           new Date::Manip::Base object for handling multiple configurations:
83
84              $base2 = new Date::Manip::Base $base1;
85              $base2 = $base1->new();
86
87           Either of the following will create a new Date::Manip::TZ object
88           with the same Date::Manip::Base object embedded in it:
89
90              $tz2   = new Date::Manip::TZ $tz1;
91              $tz2   = $tz1->new();
92
93           The new base object will initially have the same configuration as
94           the original base object, but changing it's configuration will not
95           affect the original base object.
96
97           If the "\@opts" argument is passed in, it is a list reference
98           containing a list suitable for passing to the config method
99           (described below). In this case, a new Date::Manip::Base object
100           (and perhaps Date::Manip::TZ object) will be created. The new Base
101           object will start as identical to the original one (if a previously
102           defined object was used to create the new object) with the
103           additional options in @opts added.
104
105           In other words, the following are equivalent:
106
107              $date  = new Date::Manip::Date $obj,\@opts;
108
109              $base  = $obj->base();
110              $base2 = $base->new();
111              $date = new Date::Manip::Date $base2;
112              $date->config(@opts);
113
114           It should be noted that the options are applied to the NEW object,
115           not the old one. That only matters in one situation:
116
117              $base2 = new Date::Manip::Base $base1,\@opts;
118              $base2 = $base1->new(\@opts);
119
120           An optional string ($string) may be passed in only when creating a
121           Date::Manip::Date, Date::Manip::Delta, or Date::Manip::Recur
122           object.  If it is passed in when creating a Date::Manip::TZ or
123           Date::Manip::Base object, a warning will be issued, but execution
124           will continue.
125
126           If the string is included, it will be parsed to give an initial
127           value to the object. This will only be done AFTER any options are
128           handled, so the following are equivalent:
129
130              $date = new Date::Manip::Date $string,@parse_opts,\@opts;
131
132              $date = new Date::Manip::Date;
133              $date->config(@opts);
134              $date->parse($string,@parse_opts);
135
136           Once a Date::Manip::Date object (or any object in any other
137           Date::Manip class) is created, it should always be used to create
138           additional objects in order to preserve cached data for optimal
139           performance and memory usage.
140
141           The one caveat is if you are working with multiple configurations
142           as described in the Date::Manip::Objects document. In that case,
143           you may need to create completely new objects to allow multiple
144           Date::Manip::Base objects to be used.
145
146       new_config
147              $obj2 = $obj1->new_config($string,\@opts);
148
149           This creates a new instance with a new Date::Manip::Base object
150           (and possibly a new Date::Manip::TZ object).
151
152           For example,
153
154              $date2 = $date1->new_config();
155
156           creates a new Date::Manip::Date object with a new Date::Manip::TZ
157           (and Date::Manip::Base) object. Initially, it is the same
158           configuration as the original object.
159
160           If the object is a Date::Manip::Base object, the following are
161           equivalent:
162
163              $base2 = $base1->new_config();
164
165              $base2 = $base1->new();
166
167           Both $string and "\@opts" are optional. They are used in the same
168           way they are used in the new method.
169
170       new_date
171       new_delta
172       new_recur
173           These are shortcuts for specifying the class. The following sets of
174           calls are all equivalent:
175
176              $date  = $obj->new_date();
177              $date  = new Date::Manip::Date($obj);
178
179              $delta = $obj->new_delta();
180              $delta = new Date::Manip::Date($obj);
181
182           These methods all allow optional "($string,\@opts)" arguments.
183

OTHER METHODS

185       base
186       tz
187              $base = $obj->base();
188
189           This returns the Date::Manip::Base object associated with the given
190           object.
191
192           If $obj is a Date::Manip::Base object, nothing is returned (i.e. it
193           doesn't create a new copy of the object).
194
195              $tz = $obj->tz();
196
197           This returns the Date::Manip::TZ object associated with the given
198           object. If $obj is a Date::Manip::TZ or Date::Manip::Base object,
199           nothing is returned.
200
201       config
202              $obj->config($var1,$val1,$var2,$val2,...);
203
204           This will set the value of any configuration variables. Please
205           refer to the Date::Manip::Config manual for a list of all
206           configuration variables and their description.
207
208       get_config
209              @var = $obj->get_config();
210              $val = $obj->get_config($var1);
211              @val = $obj->get_config($var1,$var2,...);
212
213           This queries the current config values.  With no argument, it will
214           return the list of config variables (all lowercase).
215
216           With one or more arguments, it returns the current values for the
217           config variables passed in (case insensitive).
218
219       err
220              $err = $obj->err();
221
222           This will return the full error message if the previous operation
223           failed for any reason.
224
225              $obj->err(1);
226
227           will clear the error code.
228
229       is_date
230       is_delta
231       is_recur
232              $flag = $obj->is_date();
233
234           Returns 0 or 1, depending on the object. For example, a
235           Date::Manip::Date object returns 1 with the is_date method, and 0
236           for the other two.
237
238       version
239              $vers = $obj->version($flag);
240
241           This returns the version of Date::Manip.
242
243           If $flag is passed in, and $obj is not a Date::Manip::Base object,
244           the version and timezone information will be passed back.
245

KNOWN BUGS

247       None known.
248

BUGS AND QUESTIONS

250       Please refer to the Date::Manip::Problems documentation for information
251       on submitting bug reports or questions to the author.
252

SEE ALSO

254       Date::Manip        - main module documentation
255

LICENSE

257       This script is free software; you can redistribute it and/or modify it
258       under the same terms as Perl itself.
259

AUTHOR

261       Sullivan Beck (sbeck@cpan.org)
262
263
264
265perl v5.30.1                      2019-12-09               Date::Manip::Obj(3)
Impressum