Олег Пронин > Panda-Date-1.1 > Panda::Date::Int

Download:
Panda-Date-1.1.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source   Latest Release: Panda-Date-2.4

NAME ^

Panda::Date::Int - Interval date object.

DESCRIPTION ^

Interval date is a length of time bound to particular point in time. Interval date consists of start date and end date.

CLASS METHODS ^

new($date | $epoch | \@ymdhms | \%ymdhms | $sql_fmt, $date | $epoch | \@ymdhms | \%ymdhms | $sql_fmt)

Creates interval object from 2 dates. Input data can be anything that date() constructor supports.

OBJECT METHODS ^

set_from($date | $epoch | \@ymdhms | \%ymdhms | $sql_fmt, $date | $epoch | \@ymdhms | \%ymdhms | $sql_fmt)

Set interval from data. This is much faster than creating new object.

from([$from])

Lower date, Panda::Date.

till([$till])

Upper date, Panda::Date.

sec(), secs, second, seconds, duration

Converts interval to accurate number of seconds between from() and till().

imin(), imins, iminute, iminutes

Converts interval to accurate integer number of minutes between from() and till(). Equals int(sec/60).

min(), mins, minute, minutes

Converts interval to accurate number of minutes between from() and till(). Equals sec/60.

ihour(), ihours

Converts interval to accurate integer number of hours between from() and till(). Equals int(sec/3600).

hour(), hours

Converts interval to accurate number of hours between from() and till(). Equals sec/3600.

iday(), idays

Converts interval to accurate integer number of days between from() and till(). Not always equals int(sec/86400).

day(), days

Converts interval to accurate number of days between from() and till(). Not always equals sec/86400.

imonth(), imonths, imon, imons

Converts interval to accurate integer number of months between from() and till().

month(), months, mon, mons

Converts interval to accurate number of months between from() and till(). Fractional part are based on how many days left till last day of month.

iyear(), iyears

Converts interval to accurate integer number of years between from() and till().

year(), years

Converts interval to accurate number of years between from() and till().

relative ()

Returns Panda::Date::Rel that equals till() minus from(). Keep in mind that ->duration not always equal to ->relative->duration ! But from() + relative() always equals till()

'+', add($reldate | $rel_string | $seconds | \@rel_array | \%rel_hash)

Adds relative date to interval, i.e. adds reldate to it's lower and upper dates. Reldate can be Panda::Date::Rel object or any data valid for its constructor.

'+=', add_me($reldate | $rel_string | $seconds | \@rel_array | \%rel_hash)

Same as add(), but changes current object instead of creating new one.

'-', subtract($reldate | $rel_string | $seconds | \@rel_array | \%rel_hash)

Subtracts relative date from interval, i.e. subtracts reldate from its upper and lower dates. Reldate can be Panda::Date::Rel object or any data valid for its constructor.

'-=', subtract_me($reldate | $rel_string | $seconds | \@rel_array | \%rel_hash)

Same as subtract(), but changes current object instead of creating new one.

'<=>', compare($idate | [...])

Compares 2 interval dates and return -1, 0 or 1. It's based on duration(). Interval date can be number (duration), Panda::Date::Int object or arrayref with constructor data.

'eq', equals($idate | [...])

Compares 2 intervals and returns true or false. It's based on full equality (i.e. from1 eq from2 and till1 eq till2). Interval date can be Panda::Date::Int object or arrayref with constructor data.

'neg', negative() - unary '-'

Swap from and till.

negative_me()

Same as negative(), but changes current object instead of creating new one.

OPERATOR OVERLOAD RULES ^

See screenshot http://crazypanda.ru/v/clip2net/p/F/0WuXfVRKMM.png

AUTHOR ^

Pronin Oleg <syber@cpan.org>, Crazy Panda, CP Decision LTD

LICENSE ^

You may distribute this code under the same terms as Perl itself.

syntax highlighting: