Creates a new incomplete date:
Any parameters not given default to undef.
Calling the new() method without parameters creates a completely undefined datetime:
from_day_of_year( ... )
This constructor takes the same arguments as can be given to the new() method, except that it does not accept a month or day argument. Instead, it requires both year and day_of_year. The day of year must be between 1 and 366, and 366 is only allowed for leap years.
from_object( object => $object, ... )
This class method can be used to construct a new DateTime::Incomplete object from any object that implements the utc_rd_values() method. All DateTime::Calendar modules must implement this method in order to provide cross-calendar compatibility. This method accepts a locale parameter.
If the object passed to this method has a time_zone() method, that is used to set the time zone. Otherwise UTC is used.
|o||from_epoch( ... )|
now( ... )
This class method is equivalent to DateTime->now.
today( ... )
This class method is equivalent to now(), but it leaves hour, minute, second and nanosecond undefined.
Creates a new object with the same information as the object this method is called on.
o year o month o day o hour o minute o second o nanosecond o time_zone o locale
These methods returns the field value for the object, or undef.
These values can also be accessed using the same alias methods available in DateTime.pm, such as mon(), mday(), etc.
o has_year o has_month o has_day o has_hour o has_minute o has_second o has_nanosecond o has_time_zone o has_locale o has_date o has_time
Returns a boolean value indicating whether the corresponding component is defined.
has_date tests for year, month, and day.
has_time tests for hour, minute, and second.
$has_date = $dti->has( year, month, day );
@fields = $dti->defined_fields; # list of field names
Returns a list containing the names of the fields that are defined.
o datetime, ymd, date, hms, time, iso8601, mdy, dmy o epoch o hires_epoch o is_dst o utc_rd_values o utc_rd_as_seconds
my $epoch = $dti->epoch( base => $dt );
These methods are equivalent to the DateTime methods with the same name.
They all accept a base argument to use in order to calculate the methods return values.
If no base argument is given, then today is used.
o is_finite, is_infinite
Incomplete dates are always finite.
o strftime( $format, ... )
This method implements functionality similar to the strftime() method in C. However, if given multiple format strings, then it will return multiple scalars, one for each format string.
See the strftime Specifiers section in the DateTime.pm documentation for a list of all possible format specifiers.
Undefined fields are replaced by xx or xxxx as appropriate.
All other accessors, such as day_of_week(), or week_year() are computed from the base values for a datetime. When these methods are called, they return the requested information if there is enough data to compute them, otherwise they return undef
o add_duration o add o subtract_duration o subtract o subtract_datetime o subtract_datetime_absolute o delta_md o delta_days o delta_ms o compare o compare_ignore_floating o DefaultLanguage
Use this to set or undefine a datetime field:
This method takes the same arguments as the set() method in DateTime.pm, but it can accept undef for any value.
This method accepts either a time zone object or a string that can be passed as the name parameter to DateTime::TimeZone->new().
You can remove time zone information by calling this method with the value undef.
o truncate( to => ... )
This method allows you to reset some of the local time components in the object to their zero values. The to parameter is used to specify which values to truncate, and it may be one of year, month, day, hour, minute, or second. For example, if month is specified, then the local day becomes 1, and the hour, minute, and second all become 0.
DateTime::Incomplete objects also have a number of methods unique to this class.
o base o has_base o is_undef o can_be_datetime
The year field must be valid, followed by a sequence of valid fields.
Can be datetime: 2003-xx-xxTxx:xx:xx 2003-10-xxTxx:xx:xx 2003-10-13Txx:xx:xx Can not be datetime: 2003-10-13Txx:xx:30 xxxx-10-13Txx:xx:30
The default value for base is undef, which means no validation is made on input.
This method takes an optional base parameter and returns a complete datetime.
This method may die if it results in a datetime that doesnt actually exist, such as February 30, for example.
This method generates the set of all possible datetimes that fit into an incomplete datetime definition.
Those recurrences are DateTime::Set objects:
$dt_next_xmas = $dti->to_recurrence->next( DateTime->today );
Incomplete dates that have the year defined will generate finite sets. This kind of set can take a lot of resources (RAM and CPU). The following incomplete datetime would generate the set of all seconds in 2003:
Recurrences are generated with up to 1 second resolution. The nanosecond value is ignored.
This method generates the set of all possible spans that fit into an incomplete datetime definition.
o start o end o to_span
These methods view an incomplete datetime as a time span.
For example, the incomplete datetime 2003-xx-xxTxx:xx:xx starts in 2003-01-01T00:00:00 and ends in 2004-01-01T00:00:00.
The to_span method returns a DateTime::Span object.
An incomplete datetime without an year spans forever. Start and end datetimes are undef.
2003-xx-xx contains 2003-12-24 2003-xx-xx does not contain 1999-12-14
o previous / next / closest
$dt2 = $dti->next( $dt );
The next() returns the first complete date after or equal to the given datetime.
The previous() returns the first complete date before or equal to the given datetime.
The closest() returns the closest complete date (previous or next) to the given datetime.
All of these methods return undef if there is no matching complete datetime.
If no datetime is given, these methods use the base datetime.
Note: The definition of previous() and next() is different from the methods of the same name in the DateTime::Set class.
The datetimes are generated with 1 nanosecond precision. The last time value of a given day is 23:59:59.999999999 (for non leapsecond days).
Support for this module is provided via the email@example.com email list. See http://lists.perl.org/ for more details.
Flavio S. Glock <fglock[at]cpan.org>
With Ben Bennett <fiji[at]ayup.limey.net>, Claus Farber <claus[at]xnfrber-gra.muc.de>, Dave Rolsky <autarch[at]urth.org>, Eugene Van Der Pijll <pijll[at]gmx.net>, Rick Measham <rick[at]isite.net.au>, and the DateTime team.
Copyright (c) 2003 Flavio S. Glock. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
firstname.lastname@example.org mailing list
|perl v5.20.3||DATETIME::INCOMPLETE (3)||2015-11-10|