App::Chart::Timebase -- timebases
App::Chart::Timebase object represents a date/time period and a starting point.
Dates in a timebase are integers starting from 0 for the starting point. For example a timebase might be weeks starting from 19 Nov 2007, in which case that week is 0, the following week is 1, etc. Methods on the timebase objects allow conversion of year/month/day dates to or from such an index number.
Create and return a new timebase object representing the given days/weeks/etc type of period, and with a 0 at the given
$start is an ISO format string like "2007-12-31".
Days means weekdays, ie. trading days. Weeks is calendar weeks starting from each Monday, through to the following Sunday. Months is calendar months. Quarters are calendar quarters like Jan/Feb/Mar then Apr/May/Jun, etc.
Return an ISO date string like "2007-12-31" for the given
$t timebase index (an integer). For example,
my $timebase = App::Chart::Timebase::Days->new_from_iso ('2008-05-01'); my $iso = $timebase->to_iso (5); # $iso is '2008-05-08' (weekday 5 counting from 0 at 1 May)
$timebase->from_ymd_floor ($year, $month, $day)
Return a time value (an integer) in
$timebase which corresponds to the given date, either as values
$day, or an ISO date string
$str like "2007-12-31".
If the date is not representable in
$timebase, then for
floor the return is the next earlier timebase value or for
ceil the next later. This only arises on a
Days timebase when the date requested is a Saturday or Sunday. In that case
floor gives the preceding Friday or
ceil the following Monday.
$timebase->convert_from_floor ($from_timebase, $from_t)
$timebase->convert_from_ceil ($from_timebase, $from_t)
Convert an time value in
$from_timebase to a value in
$timebase. The two timebases can have different starting points and different units, such as converting a day number into a week number.
When the destination
$timebase is a higher resolution than
convert_from_floor version gives the start of the
$from_t period and the
convert_from_ceil version gives the end. For example if
$from_timebase is years but the destination
$timebase is months then
floor gives the first month (ie. January) in the
$from_t year and
ceil gives the last month (ie. December).
strftime formatted string which is timebase value
$t (an integer) under
$format. For example,
$timebase->strftime ('%d %b %Y', $t) # gives say "31 December 2007"
Return today's date as an integer in
$timebase. The optional
$timezone is a
App::Chart::TZ object to use, or the default is local time.
Return a string which is an adjective for the
$timebase. For example on a years timebase the return would be
"Yearly". The string is translated through the usual Chart internationalizations if possible.