NAME
Date::Parser::Date - Simple date object
VERSION
Version 0.4
SYNOPSIS
my $date = Date::Parser::Date->new(
year => $year,
month => $month,
day => $day,
hour => $hour,
min => $min,
sec => $sec,
);
# or Date::Parser::Date->new(unixtime => $unixtime);
DESCRIPTION
A simple date object.
METHODS
new(%opts)
The constructor. Attempts to construct sensible date and time values based on a simple algorithm. See "CONSTRUCTOR_PARAMETERS".
If unixtime is passed, it is used and other values are populated.
If year, month, day, hour, min and sec are provided, populates unixtime.
If only year, month and day are provided, uses all possible time values provided, and excepts noon otherwise - then populates unixtime.
If only hour and min (and optionally sec) are defined, sets date for today. Afterwards, unixtime is populated.
time2str($format)
Returns Date::Format::time2str($format, $self->unixtime).
unixtime
Returns date in unixtime.
calc($date)
Expects Date::Parser::Date-object. Returns a new Date::Parser::Date-object representing the time between self and given $date.
cmp($date)
Expects Date::Parser::Date-object. Compares dates. Returns -1 if this object is before $date, 0 if dates match and 1 if this object is after $date.
assign($key, $value)
Sets/overwrites a parameter $key with $value.
CONSTRUCTOR PARAMETERS
The constructor accepts following parameters:
unixtime
Seconds since 1.1.1970, e.g. 1295784779
year
Integer year, e.g. 2 or 2011
month
Integer month (from 0-11).
day
Integer day of the month (from 1-31).
hour
Integer hour in 24-hour format (from 0-23).
min
Integer minute (from 0-59).
sec
Integer second (from 0-59).
CAVEATS
This module doesn't verify the sanity of values given e.g. year => -102932.124
AUTHOR
Heikki Mehtänen, <heikki@mehtanen.fi>
COPYRIGHT & LICENSE
Copyright 2011 Heikki Mehtänen, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.