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
$startis 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
$ttimebase 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
$timebasewhich corresponds to the given date, either as values
$day, or an ISO date string
If the date is not representable in
$timebase, then for
floorthe return is the next earlier timebase value or for
ceilthe next later. This only arises on a
Daystimebase when the date requested is a Saturday or Sunday. In that case
floorgives the preceding Friday or
ceilthe following Monday.
$timebase->convert_from_floor ($from_timebase, $from_t)
$timebase->convert_from_ceil ($from_timebase, $from_t)
Convert an time value in
$from_timebaseto 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
$timebaseis a higher resolution than
convert_from_floorversion gives the start of the
$from_tperiod and the
convert_from_ceilversion gives the end. For example if
$from_timebaseis years but the destination
$timebaseis months then
floorgives the first month (ie. January) in the
ceilgives the last month (ie. December).
- $timebase->strftime ($format, $t)
strftimeformatted string which is timebase value
$t(an integer) under
$format. For example,
$timebase->strftime ('%d %b %Y', $t) # gives say "31 December 2007"
- $timebase->today ()
- $timebase->today ($timezone)
Return today's date as an integer in
$timebase. The optional
App::Chart::TZobject 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.