This module contains a set of methods used by all Date::Manip classes listed above.
In the method descriptions below, Date::Manip::Date objects will usually be used as examples, but (unless otherwise stated), all of the classes listed above have the same methods, and work in the same fashion.
In the examples below, any $date ($date, $date1, $date2, ...) variable is a Date::Manip::Date object. Similarly, $delta, $recur, $tz, and $base refer to objects in the appropriate class.
Any $obj variable refers to an object in any of the classes.
<B>newB> There are two ways to use the new method. They are:
$obj2 = new CLASS ($obj1,$string,\@opts); $obj2 = $obj1->new($string,\@opts)
In both cases, all arguments are optional.
Here, CLASS is the class of the new object. For example:
if $obj1 is available, the new object will share as much information from the old object as possible. The class of the new object may be derived from the old object as well.
For example, if you call either of these:
$date2 = new Date::Manip::Date $date1; $date2 = $date1->new();
When specifying CLASS and including an old object, objects do not need to be of the same class. For example, the following are all valid:
You can even do:
There are two special cases. Either of the following will create a new Date::Manip::Base object for handling multiple configurations:
$base2 = new Date::Manip::Base $base1; $base2 = $base1->new();
$tz2 = new Date::Manip::TZ $tz1; $tz2 = $tz1->new();
If the \@opts argument is passed in, it is a list reference containing a list suitable for passing to the <B>configB> method (described below). In this case, a new Date::Manip::Base object (and perhaps Date::Manip::TZ object) will be created. The new Base object will start as identical to the original one (if a previously defined object was used to create the new object) with the additional options in @opts added.
In other words, the following are equivalent:
It should be noted that the options are applied to the NEW object, not the old one. That only matters in one situation:
$base2 = new Date::Manip::Base $base1,\@opts; $base2 = $base1->new(\@opts);
An optional string ($string) may be passed in only when creating a Date::Manip::Date, Date::Manip::Delta, or Date::Manip::Recur object. If it is passed in when creating a Date::Manip::TZ or Date::Manip::Base object, a warning will be issued, but execution will continue.
If the string is included, it will be parsed to give an initial value to the object. This will only be done AFTER any options are handled, so the following are equivalent:
Note that it is generally not a good idea to pass in $string since all of the parse methods allow (but do not require) additional arguments, and this ability is not supported when passing in $string to the new method. As a result, its generally a better practice to call the parse method separately.
Once a Date::Manip::Date object (or any object in any other Date::Manip class) is created, it should always be used to create additional objects in order to preserve cached data for optimal performance and memory usage.
The one caveat is if you are working with multiple configurations as described in the Date::Manip::Objects document. In that case, you may need to create completely new objects to allow multiple Date::Manip::Base objects to be used.
<B>new_configB> $obj2 = $obj1->new_config($string,\@opts);
$date2 = $date1->new_config();
If the object is a Date::Manip::Base object, the following are equivalent:
$base2 = $base1->new_config(); $base2 = $base1->new();
Both $string and \@opts are optional. They are used in the same way they are used in the new method.
<B>new_dateB> <B>new_deltaB> <B>new_recurB> These are shortcuts for specifying the class. The following sets of calls are all equivalent:
These methods all allow optional ($string,\@opts) arguments.
This returns the Date::Manip::Base object associated with the given object.
If $obj is a Date::Manip::Base object, nothing is returned (i.e. it doesnt create a new copy of the object).
$tz = $obj->tz();
<B>configB> $obj->config($var1,$val1,$var2,$val2,...); <B>get_configB> @var = $obj->get_config(); $val = $obj->get_config($var1); @val = $obj->get_config($var1,$var2,...);
This queries the current config values. With no argument, it will return the list of config variables (all lowercase).
With one or more arguments, it returns the current values for the config variables passed in (case insensitive).
<B>errB> $err = $obj->err();
This will return the full error message if the previous operation failed for any reason.
will clear the error code.
<B>is_dateB> <B>is_deltaB> <B>is_recurB> $flag = $obj->is_date();
Returns 0 or 1, depending on the object. For example, a Date::Manip::Date object returns 1 with the is_date method, and 0 for the other two.
<B>versionB> $vers = $obj->version($flag);
Please refer to the Date::Manip::Problems documentation for information on submitting bug reports or questions to the author.
Date::Manip - main module documentation
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Sullivan Beck (email@example.com)
|perl v5.20.3||DATE::MANIP::OBJ (3)||2015-06-01|