Old_Timeperiod_Model Class Reference

A model used by reports to lookup when report times and timeperiods start and stop. More...

Public Member Functions

 __construct ($options)
 Warning: you should not use this directly - see instance().
 test_export ()
 Export internal state, only to be able to write tests so we can isolate and verify the timeperiod import.
 set_timeperiod_data (TimePeriod_Model $period=NULL)
 Setup the data to base the timeperiod on.
 active_time ($start, $stop)
 Returns the number of active seconds "inside" the timeperiod during the start -> stop interval.
 inside ($timestamp)
 Returns whether the given timestamp is inside timeperiod.
 resolve_timeperiods ()
 Resolve timeperiods, both the actual timeperiods and the exclusions.

Static Public Member Functions

static instance ($options)
 Return an instance from a Report_options object.

Data Fields

 $start_time = false
 Report start.
 $end_time = false
 Report stop.
 $tp_exceptions = array()
 Timeperiod exceptions.
 $tp_excludes = array()
 Timeperiod excludes.
const DATERANGE_CALENDAR_DATE = 0
 eg: 2001-01-01 - 2010-11-21 / 3 (specific complete calendar date)
const DATERANGE_MONTH_DATE = 1
 eg: july 4 - november 15 / 3 (specific month)
const DATERANGE_MONTH_DAY = 2
 eg: day 1 - 25 / 5 (generic month)
const DATERANGE_MONTH_WEEK_DAY = 3
 eg: thursday 1 april - tuesday 2 may / 2 (specific month)
const DATERANGE_WEEK_DAY = 4
 eg: thursday 3 - monday 4 (generic month)
const DATERANGE_TYPES = 5
 FIXME: incomprehensible magic.

Static Public Attributes

static $precreated = array()
 Please do not touch this outside of tests, it's a cache for performance purposes.

Detailed Description

A model used by reports to lookup when report times and timeperiods start and stop.

This sounds real easy, until you start to look at nagios' less trivial timeperiod definitions.

You should call the instance() method to get a timeperiod instance, which might be shared with other users. This class will call instance() itself, so exceptions to exceptions work.


Member Function Documentation

Old_Timeperiod_Model::active_time ( start,
stop 
)

Returns the number of active seconds "inside" the timeperiod during the start -> stop interval.

Parameters:
$start,: A timestamp in the unix epoch notation
$stop,: A timestamp in the unix epoch notation
Returns:
The number of seconds included in both $stop - $start and the timeperiod set for this report as an integer in the unix epoch notation
Old_Timeperiod_Model::inside ( timestamp  ) 

Returns whether the given timestamp is inside timeperiod.

Parameters:
$timestamp,: A timestamp in the unix epoch notation
Returns:
TRUE if the timestamp is inside the timeperiod, FALSE otherwise
static Old_Timeperiod_Model::instance ( options  )  [static]

Return an instance from a Report_options object.

Parameters:
$options Report_options class, or possibly an array mock
Old_Timeperiod_Model::set_timeperiod_data ( TimePeriod_Model period = NULL  ) 

Setup the data to base the timeperiod on.

You really shouldn't be using this, unless you're a test and want to mock a timeperiod

Parameters:
$period A timeperiod db result
Returns:
true on success, false otherwise

The documentation for this class was generated from the following file:
 All Data Structures Functions Variables

Generated on 19 Dec 2018 for ninja by  doxygen 1.6.1