FIX::TimeRange Class Reference

Keeps track of when session is active. More...

`#include <TimeRange.h>`

Collaboration diagram for FIX::TimeRange:
[legend]

## Public Member Functions

| TimeRange (const UtcTimeOnly &startTime, const UtcTimeOnly &endTime, int startDay=-1, int endDay=-1)
| TimeRange (const LocalTimeOnly &startTime, const LocalTimeOnly &endTime, int startDay=-1, int endDay=-1)
bool | isInRange (const DateTime &dateTime, int day)
bool | isInRange (const UtcTimeStamp &dateTime)
bool | isInRange (const LocalTimeStamp &dateTime)
bool | isInSameRange (const UtcTimeStamp &time1, const UtcTimeStamp &time2)
bool | isInSameRange (const LocalTimeStamp &time1, const LocalTimeStamp &time2)

## Static Public Member Functions

static bool | isInRange (const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
static bool | isInRange (const UtcTimeOnly &startTime, const UtcTimeOnly &endTime, int startDay, int endDay, const DateTime &time, int day)
static bool | isInRange (const UtcTimeOnly &startTime, const UtcTimeOnly &endTime, int startDay, int endDay, const DateTime &time)
static bool | isInSameRange (const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time1, const DateTime &time2)
static bool | isInSameRange (const UtcTimeOnly &startTime, const UtcTimeOnly &endTime, int startDay, int endDay, const DateTime &time1, const DateTime &time2)
static bool | isInRange (const LocalTimeOnly &start, const LocalTimeOnly &end, const DateTime &time)
static bool | isInRange (const LocalTimeOnly &startTime, const LocalTimeOnly &endTime, int startDay, int endDay, const DateTime &time, int day)
static bool | isInRange (const LocalTimeOnly &startTime, const LocalTimeOnly &endTime, int startDay, int endDay, const DateTime &time)
static bool | isInSameRange (const LocalTimeOnly &start, const LocalTimeOnly &end, const DateTime &time1, const DateTime &time2)
static bool | isInSameRange (const LocalTimeOnly &startTime, const LocalTimeOnly &endTime, int startDay, int endDay, const DateTime &time1, const DateTime &time2)

## Private Member Functions

bool | isInSameRange (const DateTime &time1, const DateTime &time2)

## Static Private Member Functions

static bool | isInRange (const DateTime &start, const DateTime &end, const DateTime &time)
static bool | isInRange (const DateTime &startTime, const DateTime &endTime, int startDay, int endDay, const DateTime &time, int day)
static bool | isInRange (const DateTime &startTime, const DateTime &endTime, int startDay, int endDay, const DateTime &time)
static bool | isInSameRange (const DateTime &start, const DateTime &end, const DateTime &time1, const DateTime &time2)
static bool | isInSameRange (const DateTime &startTime, const DateTime &endTime, int startDay, int endDay, const DateTime &time1, const DateTime &time2)

## Private Attributes

UtcTimeOnly | m_startTime
UtcTimeOnly | m_endTime
int | m_startDay
int | m_endDay
bool | m_useLocalTime

## Detailed Description

Keeps track of when session is active.

Definition at line 34 of file TimeRange.h.

## Constructor & Destructor Documentation

## TimeRange() [1/2]

FIX::TimeRange::TimeRange | ( | const UtcTimeOnly & | startTime,
|  | const UtcTimeOnly & | endTime,
|  | int | startDay = `-1`,
|  | int | endDay = `-1`
| ) |  |

Definition at line 31 of file TimeRange.cpp.

: m_startTime( startTime ), m_endTime( endTime ),
m_startDay( startDay ), m_endDay( endDay ),
m_useLocalTime( false )
{
if( startDay > 0
&& endDay > 0
&& startDay == endDay
&& endTime > startTime )
{ m_endTime = m_startTime; }
}
FIX::TimeRange::m_startTime
UtcTimeOnly m_startTime
Definition TimeRange.h:250
FIX::TimeRange::m_startDay
int m_startDay
Definition TimeRange.h:252
FIX::TimeRange::m_useLocalTime
bool m_useLocalTime
Definition TimeRange.h:254
FIX::TimeRange::m_endTime
UtcTimeOnly m_endTime
Definition TimeRange.h:251
FIX::TimeRange::m_endDay
int m_endDay
Definition TimeRange.h:253

References m_endTime, and m_startTime.

## TimeRange() [2/2]

FIX::TimeRange::TimeRange | ( | const LocalTimeOnly & | startTime,
|  | const LocalTimeOnly & | endTime,
|  | int | startDay = `-1`,
|  | int | endDay = `-1`
| ) |  |

Definition at line 46 of file TimeRange.cpp.

: m_startTime( startTime ), m_endTime( endTime ),
m_startDay( startDay ), m_endDay( endDay ),
m_useLocalTime( true )
{
if( startDay > 0
&& endDay > 0
&& startDay == endDay
&& endTime > startTime )
{ m_endTime = m_startTime; }
}

References m_endTime, and m_startTime.

## Member Function Documentation

## isInRange() [1/12]

bool FIX::TimeRange::isInRange | ( | const DateTime & | dateTime,
|  | int | day
| ) |  |

inline

Definition at line 185 of file TimeRange.h.

{
if( m_startDay < 0 && m_endDay < 0 )
return isInRange( m_startTime, m_endTime, dateTime );
else
return isInRange
( m_startTime, m_endTime, m_startDay, m_endDay, dateTime, day );
}
FIX::TimeRange::isInRange
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition TimeRange.h:43

References isInRange(), m_endDay, m_endTime, m_startDay, and m_startTime.

## isInRange() [2/12]

bool FIX::TimeRange::isInRange | ( | const DateTime & | start,
|  | const DateTime & | end,
|  | const DateTime & | time
| ) |  |

static private

Definition at line 61 of file TimeRange.cpp.

{
UtcTimeOnly timeOnly (time);
if( start < end )
return( timeOnly >= start && timeOnly <= end );
else
return( timeOnly >= start || timeOnly <= end );
}
FIX::TYPE::UtcTimeOnly
@ UtcTimeOnly
Definition FieldTypes.h:933

## isInRange() [3/12]

bool FIX::TimeRange::isInRange | ( | const DateTime & | startTime,
|  | const DateTime & | endTime,
|  | int | startDay,
|  | int | endDay,
|  | const DateTime & | time
| ) |  |

static private

Definition at line 109 of file TimeRange.cpp.

{
return isInRange( startTime, endTime, startDay, endDay, time, time.getWeekDay() );
}

References FIX::DateTime::getWeekDay(), and isInRange().

## isInRange() [4/12]

bool FIX::TimeRange::isInRange | ( | const DateTime & | startTime,
|  | const DateTime & | endTime,
|  | int | startDay,
|  | int | endDay,
|  | const DateTime & | time,
|  | int | day
| ) |  |

static private

Definition at line 73 of file TimeRange.cpp.

{
UtcTimeOnly timeOnly (time);
if( startDay == endDay )
{
if( day != startDay )
return true;
return isInRange( startTime, endTime, time );
}
else if( startDay < endDay )
{
if( day < startDay || day > endDay )
return false;
else if( day == startDay && timeOnly < startTime )
return false;
else if( day == endDay && timeOnly > endTime )
return false;
}
else if( startDay > endDay )
{
if( day < startDay && day > endDay )
return false;
else if( day == startDay && timeOnly < startTime )
return false;
else if( day == endDay && timeOnly > endTime )
return false;
}
return true;
}

References isInRange().

## isInRange() [5/12]

static bool FIX::TimeRange::isInRange | ( | const LocalTimeOnly & | start,
|  | const LocalTimeOnly & | end,
|  | const DateTime & | time
| ) |  |

inline static

Definition at line 99 of file TimeRange.h.

{
return isInRange
( (DateTime)start, (DateTime)end, (DateTime)time );
}

References isInRange().

## isInRange() [6/12]

static bool FIX::TimeRange::isInRange | ( | const LocalTimeOnly & | startTime,
|  | const LocalTimeOnly & | endTime,
|  | int | startDay,
|  | int | endDay,
|  | const DateTime & | time
| ) |  |

inline static

Definition at line 120 of file TimeRange.h.

{
return isInRange
( (DateTime)startTime, (DateTime)endTime,
startDay, endDay,
(DateTime)time );
}

References isInRange().

## isInRange() [7/12]

static bool FIX::TimeRange::isInRange | ( | const LocalTimeOnly & | startTime,
|  | const LocalTimeOnly & | endTime,
|  | int | startDay,
|  | int | endDay,
|  | const DateTime & | time,
|  | int | day
| ) |  |

inline static

Definition at line 107 of file TimeRange.h.

{
return isInRange
( (DateTime)startTime, (DateTime)endTime,
startDay, endDay,
(DateTime)time, day );
}

References isInRange().

## isInRange() [8/12]

bool FIX::TimeRange::isInRange | ( | const LocalTimeStamp & | dateTime | ) |

inline

Definition at line 205 of file TimeRange.h.

{
if( !m_useLocalTime )
{
LocalTimeStamp utcDateTime( dateTime.getTimeT() );
return isInRange( utcDateTime, utcDateTime.getWeekDay() );
}
return isInRange( dateTime, dateTime.getWeekDay() );
}

References FIX::DateTime::getTimeT(), FIX::DateTime::getWeekDay(), isInRange(), and m_useLocalTime.

## isInRange() [9/12]

static bool FIX::TimeRange::isInRange | ( | const UtcTimeOnly & | start,
|  | const UtcTimeOnly & | end,
|  | const DateTime & | time
| ) |  |

inline static

Definition at line 43 of file TimeRange.h.

{
return isInRange
( (DateTime)start, (DateTime)end, (DateTime)time );
}

References isInRange().

Referenced by FIX::SessionFactory::create(), isInRange(), isInRange(), isInRange(), isInRange(), isInRange(), isInRange(), isInRange(), isInRange(), isInRange(), isInRange(), isInRange(), isInSameRange(), isInSameRange(), FIX::Session::isLogonTime(), and FIX::Session::isSessionTime().

## isInRange() [10/12]

static bool FIX::TimeRange::isInRange | ( | const UtcTimeOnly & | startTime,
|  | const UtcTimeOnly & | endTime,
|  | int | startDay,
|  | int | endDay,
|  | const DateTime & | time
| ) |  |

inline static

Definition at line 64 of file TimeRange.h.

{
return isInRange
( (DateTime)startTime, (DateTime)endTime,
startDay, endDay,
(DateTime)time );
}

References isInRange().

## isInRange() [11/12]

static bool FIX::TimeRange::isInRange | ( | const UtcTimeOnly & | startTime,
|  | const UtcTimeOnly & | endTime,
|  | int | startDay,
|  | int | endDay,
|  | const DateTime & | time,
|  | int | day
| ) |  |

inline static

Definition at line 51 of file TimeRange.h.

{
return isInRange
( (DateTime)startTime, (DateTime)endTime,
startDay, endDay,
(DateTime)time, day );
}

References isInRange().

## isInRange() [12/12]

bool FIX::TimeRange::isInRange | ( | const UtcTimeStamp & | dateTime | ) |

inline

Definition at line 194 of file TimeRange.h.

{
if( m_useLocalTime )
{
LocalTimeStamp localDateTime( dateTime.getTimeT() );
return isInRange( localDateTime, localDateTime.getWeekDay() );
}
return isInRange( dateTime, dateTime.getWeekDay() );
}

References FIX::DateTime::getTimeT(), FIX::DateTime::getWeekDay(), isInRange(), and m_useLocalTime.

## isInSameRange() [1/9]

bool FIX::TimeRange::isInSameRange | ( | const DateTime & | start,
|  | const DateTime & | end,
|  | const DateTime & | time1,
|  | const DateTime & | time2
| ) |  |

static private

Definition at line 118 of file TimeRange.cpp.

{
if( !isInRange( start, end, time1 ) ) return false;
if( !isInRange( start, end, time2 ) ) return false;
if( time1 == time2 ) return true;
if( start < end || start == end )
{
UtcDate time1Date( time1 );
UtcDate time2Date( time2 );
return time1Date == time2Date;
}
else
{
int sessionLength = DateTime::SECONDS_PER_DAY - (start - end);
if( time1 > time2 )
{
UtcTimeOnly time2TimeOnly = UtcTimeOnly(time2);
long delta = time2TimeOnly - start;
if( delta < 0 )
delta = DateTime::SECONDS_PER_DAY - labs(delta);
return (time1 - time2) < (sessionLength - delta);
}
else
{
return (time2 - time1) < sessionLength;
}
}
}
FIX::TYPE::UtcDate
@ UtcDate
Definition FieldTypes.h:931
FIX::DateTime::SECONDS_PER_DAY
static const int64_t SECONDS_PER_DAY
Magic numbers.
Definition FieldTypes.h:66

References isInRange(), and FIX::DateTime::SECONDS_PER_DAY.

## isInSameRange() [2/9]

bool FIX::TimeRange::isInSameRange | ( | const DateTime & | startTime,
|  | const DateTime & | endTime,
|  | int | startDay,
|  | int | endDay,
|  | const DateTime & | time1,
|  | const DateTime & | time2
| ) |  |

static private

Definition at line 156 of file TimeRange.cpp.

{
if( !isInRange( startTime, endTime, startDay, endDay, time1, time1.getWeekDay() ) )
return false;
if( !isInRange( startTime, endTime, startDay, endDay, time2, time2.getWeekDay() ) )
return false;
int absoluteDay1 = time1.getJulianDate() - time1.getWeekDay();
int absoluteDay2 = time2.getJulianDate() - time2.getWeekDay();
return absoluteDay1 == absoluteDay2;
}

References FIX::DateTime::getJulianDate(), FIX::DateTime::getWeekDay(), and isInRange().

## isInSameRange() [3/9]

bool FIX::TimeRange::isInSameRange | ( | const DateTime & | time1,
|  | const DateTime & | time2
| ) |  |

inline private

Definition at line 241 of file TimeRange.h.

{
if( m_startDay < 0 && m_endDay < 0 )
return isInSameRange( m_startTime, m_endTime, time1, time2 );
else
return isInSameRange
( m_startTime, m_endTime, m_startDay, m_endDay, time1, time2 );
}
FIX::TimeRange::isInSameRange
static bool isInSameRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time1, const DateTime &time2)
Definition TimeRange.h:76

References isInSameRange(), m_endDay, m_endTime, m_startDay, and m_startTime.

## isInSameRange() [4/9]

static bool FIX::TimeRange::isInSameRange | ( | const LocalTimeOnly & | start,
|  | const LocalTimeOnly & | end,
|  | const DateTime & | time1,
|  | const DateTime & | time2
| ) |  |

inline static

Definition at line 132 of file TimeRange.h.

{
return isInSameRange
( (DateTime)start, (DateTime)end,
(DateTime)time1, (DateTime)time2 );
}

References isInSameRange().

## isInSameRange() [5/9]

static bool FIX::TimeRange::isInSameRange | ( | const LocalTimeOnly & | startTime,
|  | const LocalTimeOnly & | endTime,
|  | int | startDay,
|  | int | endDay,
|  | const DateTime & | time1,
|  | const DateTime & | time2
| ) |  |

inline static

Definition at line 142 of file TimeRange.h.

{
return isInSameRange
( (DateTime)startTime, (DateTime)endTime,
startDay, endDay,
(DateTime)time1, (DateTime)time2 );
}

References isInSameRange().

## isInSameRange() [6/9]

bool FIX::TimeRange::isInSameRange | ( | const LocalTimeStamp & | time1,
|  | const LocalTimeStamp & | time2
| ) |  |

inline

Definition at line 228 of file TimeRange.h.

{
if( !m_useLocalTime )
{
UtcTimeStamp utcTime1( time1.getTimeT() );
UtcTimeStamp utcTime2( time2.getTimeT() );
return isInSameRange( (DateTime)utcTime1, (DateTime)utcTime2 );
}
return isInSameRange( (DateTime)time1, (DateTime)time2 );
}
FIX::TYPE::UtcTimeStamp
@ UtcTimeStamp
Definition FieldTypes.h:923

References FIX::DateTime::getTimeT(), isInSameRange(), and m_useLocalTime.

## isInSameRange() [7/9]

static bool FIX::TimeRange::isInSameRange | ( | const UtcTimeOnly & | start,
|  | const UtcTimeOnly & | end,
|  | const DateTime & | time1,
|  | const DateTime & | time2
| ) |  |

inline static

Definition at line 76 of file TimeRange.h.

{
return isInSameRange
( (DateTime)start, (DateTime)end,
(DateTime)time1, (DateTime)time2 );
}

References isInSameRange().

Referenced by FIX::Session::checkSessionTime(), isInSameRange(), isInSameRange(), isInSameRange(), isInSameRange(), isInSameRange(), isInSameRange(), and isInSameRange().

## isInSameRange() [8/9]

static bool FIX::TimeRange::isInSameRange | ( | const UtcTimeOnly & | startTime,
|  | const UtcTimeOnly & | endTime,
|  | int | startDay,
|  | int | endDay,
|  | const DateTime & | time1,
|  | const DateTime & | time2
| ) |  |

inline static

Definition at line 86 of file TimeRange.h.

{
return isInSameRange
( (DateTime)startTime, (DateTime)endTime,
startDay, endDay,
(DateTime)time1, (DateTime)time2 );
}

References isInSameRange().

## isInSameRange() [9/9]

bool FIX::TimeRange::isInSameRange | ( | const UtcTimeStamp & | time1,
|  | const UtcTimeStamp & | time2
| ) |  |

inline

Definition at line 216 of file TimeRange.h.

{
if( m_useLocalTime )
{
LocalTimeStamp localTime1( time1.getTimeT() );
LocalTimeStamp localTime2( time2.getTimeT() );
return isInSameRange( (DateTime)localTime1, (DateTime)localTime2 );
}
return isInSameRange( (DateTime)time1, (DateTime)time2 );
}

References FIX::DateTime::getTimeT(), isInSameRange(), and m_useLocalTime.

## Member Data Documentation

## m_endDay

int FIX::TimeRange::m_endDay

private

Definition at line 253 of file TimeRange.h.

Referenced by isInRange(), and isInSameRange().

## m_endTime

UtcTimeOnly FIX::TimeRange::m_endTime

private

Definition at line 251 of file TimeRange.h.

Referenced by isInRange(), isInSameRange(), TimeRange(), and TimeRange().

## m_startDay

int FIX::TimeRange::m_startDay

private

Definition at line 252 of file TimeRange.h.

Referenced by isInRange(), and isInSameRange().

## m_startTime

UtcTimeOnly FIX::TimeRange::m_startTime

private

Definition at line 250 of file TimeRange.h.

Referenced by isInRange(), isInSameRange(), TimeRange(), and TimeRange().

## m_useLocalTime

bool FIX::TimeRange::m_useLocalTime

private

Definition at line 254 of file TimeRange.h.

Referenced by isInRange(), isInRange(), isInSameRange(), and isInSameRange().

The documentation for this class was generated from the following files:

- TimeRange.h
- TimeRange.cpp