QuickFIX: FIX::TimeRange Class Reference

Index Source Files Annotated Class List Alphabetical Class List Class Hierarchy Graphical Class Hierarchy

# FIX::TimeRange Class Reference

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

`#include <TimeRange.h>`

Collaboration diagram for FIX::TimeRange:
[legend]

List of all members.

## 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)
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)
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)
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)
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

## Detailed Description

Keeps track of when session is active.

Definition at line 34 of file TimeRange.h.

## Constructor & Destructor Documentation

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

Definition at line 32 of file TimeRange.cpp.

References m_endTime, and m_startTime.

    00036   : m_startTime( startTime ), m_endTime( endTime ),
    00037     m_startDay( startDay ), m_endDay( endDay )
    00038   {
    00039     if( startDay > 0
    00040         && endDay > 0
    00041         && startDay == endDay
    00042         && endTime > startTime )
    00043     { m_endTime = m_startTime; }
    00044   }

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

Definition at line 46 of file TimeRange.cpp.

References m_endTime, and m_startTime.

    00050   : m_startTime( startTime ), m_endTime( endTime ),
    00051     m_startDay( startDay ), m_endDay( endDay )
    00052   {
    00053     if( startDay > 0
    00054         && endDay > 0
    00055         && startDay == endDay
    00056         && endTime > startTime )
    00057     { m_endTime = m_startTime; }
    00058   }

## Member Function Documentation

bool FIX::TimeRange::isInRange | ( | const DateTime & | dateTime | ) | `[inline]`

Definition at line 152 of file TimeRange.h.

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

    00153   {
    00154     if( m_startDay < 0 && m_endDay < 0 )
    00155       return isInRange( m_startTime, m_endTime, dateTime );
    00156     else
    00157       return isInRange
    00158         ( m_startTime, m_endTime, m_startDay, m_endDay, dateTime );
    00159   }

bool FIX::TimeRange::isInRange | ( | const DateTime & | startTime,
|  | const DateTime & | endTime,
|  | int | startDay,
|  | int | endDay,
|  | const DateTime & | time |
| ) |  |  | `[static, private]`

Definition at line 75 of file TimeRange.cpp.

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

    00080   { QF_STACK_PUSH(TimeRange::isInRange)
    00081
    00082     int currentDay = time.getWeekDay();
    00083     UtcTimeOnly timeOnly (time);
    00084
    00085     if( startDay == endDay )
    00086     {
    00087       if( currentDay != startDay )
    00088         return true;
    00089       return isInRange( startTime, endTime, time );
    00090     }
    00091     else if( startDay < endDay )
    00092     {
    00093       if( currentDay < startDay || currentDay > endDay )
    00094         return false;
    00095       else if( currentDay == startDay && timeOnly < startTime )
    00096         return false;
    00097       else if( currentDay == endDay && timeOnly > endTime )
    00098         return false;
    00099     }
    00100     else if( startDay > endDay )
    00101     {
    00102       if( currentDay < startDay && currentDay > endDay )
    00103         return false;
    00104       else if( currentDay == startDay && timeOnly < startTime )
    00105         return false;
    00106       else if( currentDay == endDay && timeOnly > endTime )
    00107         return false;
    00108     }
    00109     return true;
    00110     QF_STACK_POP
    00111   }

bool FIX::TimeRange::isInRange | ( | const DateTime & | start,
|  | const DateTime & | end,
|  | const DateTime & | time |
| ) |  |  | `[static, private]`

Definition at line 60 of file TimeRange.cpp.

References isInRange(), QF_STACK_POP, and QF_STACK_PUSH.

    00063   { QF_STACK_PUSH(TimeRange::isInRange)
    00064
    00065     UtcTimeOnly timeOnly (time);
    00066
    00067     if( start < end )
    00068       return( timeOnly >= start && timeOnly <= end );
    00069     else
    00070       return( timeOnly >= start || timeOnly <= end );
    00071
    00072     QF_STACK_POP
    00073   }

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

Definition at line 94 of file TimeRange.h.

References isInRange().

    00099   {
    00100     return isInRange
    00101       ( (DateTime)startTime, (DateTime)endTime,
    00102         startDay, endDay,
    00103         (DateTime)time );
    00104   }

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

Definition at line 86 of file TimeRange.h.

References isInRange().

    00089   {
    00090     return isInRange
    00091       ( (DateTime)start, (DateTime)end, (DateTime)time );
    00092   }

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

Definition at line 51 of file TimeRange.h.

References isInRange().

    00056   {
    00057     return isInRange
    00058       ( (DateTime)startTime, (DateTime)endTime,
    00059         startDay, endDay,
    00060         (DateTime)time );
    00061   }

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

Definition at line 43 of file TimeRange.h.

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

    00046   {
    00047     return isInRange
    00048       ( (DateTime)start, (DateTime)end, (DateTime)time );
    00049   }

bool FIX::TimeRange::isInSameRange | ( | const DateTime & | time1,
|  | const DateTime & | time2 |
| ) |  |  | `[inline, private]`

Definition at line 172 of file TimeRange.h.

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

    00173   {
    00174     if( m_startDay < 0 && m_endDay < 0 )
    00175       return isInSameRange( m_startTime, m_endTime, time1, time2 );
    00176     else
    00177       return isInSameRange
    00178         ( m_startTime, m_endTime, m_startDay, m_endDay, time1, time2 );
    00179   }

bool FIX::TimeRange::isInSameRange | ( | const LocalTimeStamp & | time1,
|  | const LocalTimeStamp & | time2 |
| ) |  |  | `[inline]`

Definition at line 166 of file TimeRange.h.

References isInSameRange().

    00167   {
    00168     return isInSameRange( (DateTime)time1, (DateTime)time2 );
    00169   }

bool FIX::TimeRange::isInSameRange | ( | const UtcTimeStamp & | time1,
|  | const UtcTimeStamp & | time2 |
| ) |  |  | `[inline]`

Definition at line 161 of file TimeRange.h.

References isInSameRange().

    00162   {
    00163     return isInSameRange( (DateTime)time1, (DateTime)time2 );
    00164   }

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 154 of file TimeRange.cpp.

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

    00160   { QF_STACK_PUSH(TimeRange::isInSameRange)
    00161
    00162     if( !isInRange( startTime, endTime, startDay, endDay, time1 ) )
    00163       return false;
    00164
    00165     if( !isInRange( startTime, endTime, startDay, endDay, time2 ) )
    00166       return false;
    00167
    00168     int absoluteDay1 = time1.getJulianDate() - time1.getWeekDay();
    00169     int absoluteDay2 = time2.getJulianDate() - time2.getWeekDay();
    00170     return absoluteDay1 == absoluteDay2;
    00171
    00172     QF_STACK_POP
    00173   }

bool FIX::TimeRange::isInSameRange | ( | const DateTime & | start,
|  | const DateTime & | end,
|  | const DateTime & | time1,
|  | const DateTime & | time2 |
| ) |  |  | `[static, private]`

Definition at line 113 of file TimeRange.cpp.

References isInRange(), isInSameRange(), QF_STACK_POP, QF_STACK_PUSH, FIX::DateTime::SECONDS_PER_DAY, and FIX::TYPE::UtcTimeOnly.

    00117   { QF_STACK_PUSH(TimeRange::isInSameRange)
    00118
    00119     if( !isInRange( start, end, time1 ) ) return false;
    00120     if( !isInRange( start, end, time2 ) ) return false;
    00121
    00122     if( time1 == time2 ) return true;
    00123
    00124     if( start < end || start == end )
    00125     {
    00126       UtcDate time1Date( time1 );
    00127       UtcDate time2Date( time2 );
    00128
    00129       return time1Date == time2Date;
    00130     }
    00131     else
    00132     {
    00133       int sessionLength = DateTime::SECONDS_PER_DAY - (start - end);
    00134
    00135       if( time1 > time2 )
    00136       {
    00137         UtcTimeOnly time2TimeOnly = UtcTimeOnly(time2);
    00138
    00139         long delta = time2TimeOnly - start;
    00140         if( delta < 0 )
    00141           delta = DateTime::SECONDS_PER_DAY - labs(delta);
    00142
    00143         return (time1 - time2) < (sessionLength - delta);
    00144       }
    00145       else
    00146       {
    00147         return (time2 - time1) < sessionLength;
    00148       }
    00149     }
    00150
    00151     QF_STACK_POP
    00152   }

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 116 of file TimeRange.h.

References isInSameRange().

    00122   {
    00123     return isInSameRange
    00124       ( (DateTime)startTime, (DateTime)endTime,
    00125         startDay, endDay,
    00126         (DateTime)time1, (DateTime)time2 );
    00127   }

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

Definition at line 106 of file TimeRange.h.

References isInSameRange().

    00110   {
    00111     return isInSameRange
    00112       ( (DateTime)start, (DateTime)end,
    00113         (DateTime)time1, (DateTime)time2 );
    00114   }

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 73 of file TimeRange.h.

References isInSameRange().

    00079   {
    00080     return isInSameRange
    00081       ( (DateTime)startTime, (DateTime)endTime,
    00082         startDay, endDay,
    00083         (DateTime)time1, (DateTime)time2 );
    00084   }

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

Definition at line 63 of file TimeRange.h.

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

    00067   {
    00068     return isInSameRange
    00069       ( (DateTime)start, (DateTime)end,
    00070         (DateTime)time1, (DateTime)time2 );
    00071   }

## Member Data Documentation

int FIX::TimeRange::m_endDay`[private]`

Definition at line 184 of file TimeRange.h.

Referenced by isInRange(), and isInSameRange().

UtcTimeOnly FIX::TimeRange::m_endTime`[private]`

Definition at line 182 of file TimeRange.h.

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

int FIX::TimeRange::m_startDay`[private]`

Definition at line 183 of file TimeRange.h.

Referenced by isInRange(), and isInSameRange().

UtcTimeOnly FIX::TimeRange::m_startTime`[private]`

Definition at line 181 of file TimeRange.h.

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

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

- /home/omiller/Development/autobuild/quickfix/src/C++/TimeRange.h
- /home/omiller/Development/autobuild/quickfix/src/C++/TimeRange.cpp