Skip to content

datatypes::timeseries::TimeStep

Time step handling for time series. More...

#include <time_step.h>

Public Functions

Name
TimeStep(const time_duration & stepDuration)
Define a time step where every step is a fixed time duration.
TimeStep(TimeStepImplementation * tsi)
TimeStep(const TimeStep & src)
Copy constructor.
TimeStep()
~TimeStep()
TimeStep & operator=(const TimeStep & rhs)
TimeStep & operator=(const time_duration & stepDuration)
Assignment operator.
TimeStep & operator=(const string & stepDuration)
bool operator==(const TimeStep & rhs) const
bool operator!=(const TimeStep & rhs) const
TimeStep operator*(int mult) const
Multiplication operator, using the time_duration multiplication operator.
TimeStep operator*(double mult) const
int operator/(const TimeStep & divisor) const
TimeStep operator/(int divisor) const
time_duration operator%(const TimeStep & other) const
bool IsRegular() const
Query if this time step is defined by a time duration in the true sense (day, week). Monthly time step would return false;.
time_duration GetRegularStepDuration() const
Gets the underlying time_duration for this time step. Exception thrown if not a regular time step.
const ptime AddSteps(const ptime & startTimeStep, size_t n) const
const ptime AddSteps(const ptime & startTimeStep, int n) const
const ptime AddSteps(const ptime & startTimeStep, double mult) const
Adds a number of steps to an instant, which can be non-integer for regular time steps. Behavior TBC for irregular time steps.
vector< ptime > AddSteps(const ptime & startTimeStep, const vector< double > timeSteps) const
Vectorized version of shifting time steps. Adds a number of steps to an instant, which can be non-integer for regular time steps. Behavior TBC for irregular time steps.
vector< ptime > AddSteps(const vector< ptime > & times, double mult) const
const time_duration GetTimeStepDuration(const ptime & startTimeStep) const
Given an instant, what is the next time instant according to this present Time step.
const ptrdiff_t GetUpperNumSteps(const ptime & start, const ptime & end) const
Gets the minimum number of time steps covering a time interval.
const ptrdiff_t GetNumSteps(const ptime & start, const ptime & end) const
Gets the maximum number of time steps from a starting instant to not get beyond an instant in time, 'end'.
const ptrdiff_t GetOffset(const ptime & start, const ptime & end) const
const void Increment(ptime * t) const
Increments an instant by one time step.
bool IsUnknown() const
Query if this object is the time step value "unknown".
string GetName() const
TimeStep Parse(const string & name)
TimeStep FromSeconds(unsigned int seconds)
TimeStep GetDaily()
TimeStep GetHourly()
TimeStep GetMonthlyQpp()
TimeStep GetUnknown()
Gets an instance of time step that is unknown. This value is indented for use in methods as a default parameter value.
ptime CreatePtime(int year, int month, int day, int hour =0, int minute =0, int second =0)
ptime PtimeFromIsoString(const string & t)
string ToString(const ptime & dt, const string & format ="YYYYMMDDThhmmss")

Detailed Description

class datatypes::timeseries::TimeStep;

Time step handling for time series.

    A TimeStep is responsible for the definition of time steps in time series 
    and the associated calculations for determining time instants and durations

Public Functions Documentation

function TimeStep

TimeStep(
    const time_duration & stepDuration
)

Define a time step where every step is a fixed time duration.

Parameters:

  • stepDuration Duration of the step.

function TimeStep

TimeStep(
    TimeStepImplementation * tsi
)

function TimeStep

TimeStep(
    const TimeStep & src
)

Copy constructor.

Parameters:

function TimeStep

TimeStep()

function ~TimeStep

~TimeStep()

function operator=

TimeStep & operator=(
    const TimeStep & rhs
)

function operator=

TimeStep & operator=(
    const time_duration & stepDuration
)

Assignment operator.

Parameters:

  • stepDuration Duration of the step.

Return: A reference to this object.

function operator=

TimeStep & operator=(
    const string & stepDuration
)

function operator==

bool operator==(
    const TimeStep & rhs
) const

function operator!=

bool operator!=(
    const TimeStep & rhs
) const

function operator*

TimeStep operator*(
    int mult
) const

Multiplication operator, using the time_duration multiplication operator.

Parameters:

  • mult The multiplier.

Return: The result of the operation.

Multiplication operator, using the time_duration multiplication operator if the argument is an integer.

function operator*

TimeStep operator*(
    double mult
) const

function operator/

int operator/(
    const TimeStep & divisor
) const

function operator/

TimeStep operator/(
    int divisor
) const

function operator%

time_duration operator%(
    const TimeStep & other
) const

function IsRegular

bool IsRegular() const

Query if this time step is defined by a time duration in the true sense (day, week). Monthly time step would return false;.

Return: true if regular, false if not.

function GetRegularStepDuration

time_duration GetRegularStepDuration() const

Gets the underlying time_duration for this time step. Exception thrown if not a regular time step.

Return: The regular step duration.

function AddSteps

const ptime AddSteps(
    const ptime & startTimeStep,
    size_t n
) const

function AddSteps

const ptime AddSteps(
    const ptime & startTimeStep,
    int n
) const

function AddSteps

const ptime AddSteps(
    const ptime & startTimeStep,
    double mult
) const

Adds a number of steps to an instant, which can be non-integer for regular time steps. Behavior TBC for irregular time steps.

Parameters:

  • startTimeStep The start time step.
  • mult The number of steps added.

Return: A ptime.

function AddSteps

vector< ptime > AddSteps(
    const ptime & startTimeStep,
    const vector< double > timeSteps
) const

Vectorized version of shifting time steps. Adds a number of steps to an instant, which can be non-integer for regular time steps. Behavior TBC for irregular time steps.

Parameters:

  • startTimeStep The start time step.
  • timeSteps The time steps.

Return: A vector

function AddSteps

vector< ptime > AddSteps(
    const vector< ptime > & times,
    double mult
) const

function GetTimeStepDuration

const time_duration GetTimeStepDuration(
    const ptime & startTimeStep
) const

Given an instant, what is the next time instant according to this present Time step.

Parameters:

  • startTimeStep The start time step.

Return: The time step duration.

function GetUpperNumSteps

const ptrdiff_t GetUpperNumSteps(
    const ptime & start,
    const ptime & end
) const

Gets the minimum number of time steps covering a time interval.

Parameters:

  • start The start of the time interval
  • end The end of the time interval

Return: the number of steps needed to get beyond 'end'

function GetNumSteps

const ptrdiff_t GetNumSteps(
    const ptime & start,
    const ptime & end
) const

Gets the maximum number of time steps from a starting instant to not get beyond an instant in time, 'end'.

Parameters:

  • start The start of the time interval
  • end The end of the time interval

Return: the number of steps needed to not get beyond 'end'

function GetOffset

const ptrdiff_t GetOffset(
    const ptime & start,
    const ptime & end
) const

function Increment

const void Increment(
    ptime * t
) const

Increments an instant by one time step.

Parameters:

  • t If non-null, the ptime to process.

function IsUnknown

bool IsUnknown() const

Query if this object is the time step value "unknown".

Return: true if unknown, false if not.

function GetName

string GetName() const

function Parse

static TimeStep Parse(
    const string & name
)

function FromSeconds

static TimeStep FromSeconds(
    unsigned int seconds
)

function GetDaily

static TimeStep GetDaily()

function GetHourly

static TimeStep GetHourly()

function GetMonthlyQpp

static TimeStep GetMonthlyQpp()

function GetUnknown

static TimeStep GetUnknown()

Gets an instance of time step that is unknown. This value is indented for use in methods as a default parameter value.

Return: The "unknown" value of the time step

function CreatePtime

static ptime CreatePtime(
    int year,
    int month,
    int day,
    int hour =0,
    int minute =0,
    int second =0
)

function PtimeFromIsoString

static ptime PtimeFromIsoString(
    const string & t
)

function ToString

static string ToString(
    const ptime & dt,
    const string & format ="YYYYMMDDThhmmss"
)

Updated on 2022-08-21 at 18:10:33 +1000