Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
FIX::TimeRange Class Reference

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

#include <TimeRange.h>

Collaboration diagram for FIX::TimeRange:
Collaboration graph
[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 49 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 46 of file TimeRange.cpp.

50  : m_startTime( startTime ), m_endTime( endTime ),
51  m_startDay( startDay ), m_endDay( endDay ),
52  m_useLocalTime( true )
53  {
54  if( startDay > 0
55  && endDay > 0
56  && startDay == endDay
57  && endTime > startTime )
58  { m_endTime = m_startTime; }
59  }

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

64  {
65  UtcTimeOnly timeOnly (time);
66 
67  if( start < end )
68  return( timeOnly >= start && timeOnly <= end );
69  else
70  return( timeOnly >= start || timeOnly <= end );
71  }
72 
73  bool TimeRange::isInRange( const DateTime& startTime,
74  const DateTime& endTime,

Member Function Documentation

◆ isInRange() [1/12]

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

Definition at line 216 of file TimeRange.h.

217  {
218  if( m_useLocalTime )
219  {
220  LocalTimeStamp localTime1( time1.getTimeT() );
221  LocalTimeStamp localTime2( time2.getTimeT() );
222  return isInSameRange( (DateTime)localTime1, (DateTime)localTime2 );
223  }

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

◆ isInRange() [2/12]

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

Definition at line 76 of file TimeRange.cpp.

79  {
80  UtcTimeOnly timeOnly (time);
81 
82  if( startDay == endDay )
83  {
84  if( day != startDay )
85  return true;
86  return isInRange( startTime, endTime, time );

References isInRange().

◆ isInRange() [3/12]

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

Definition at line 124 of file TimeRange.cpp.

129  {
130  UtcDate time1Date( time1 );
131  UtcDate time2Date( time2 );

◆ isInRange() [4/12]

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

Definition at line 88 of file TimeRange.cpp.

89  {
90  if( day < startDay || day > endDay )
91  return false;
92  else if( day == startDay && timeOnly < startTime )
93  return false;
94  else if( day == endDay && timeOnly > endTime )
95  return false;
96  }
97  else if( startDay > endDay )
98  {
99  if( day < startDay && day > endDay )
100  return false;
101  else if( day == startDay && timeOnly < startTime )
102  return false;
103  else if( day == endDay && timeOnly > endTime )
104  return false;
105  }
106  return true;
107  }
108 
109  bool TimeRange::isInRange( const DateTime& startTime,
110  const DateTime& endTime,
111  int startDay,
112  int endDay,
113  const DateTime& time )
114  {
115  return isInRange( startTime, endTime, startDay, endDay, time, time.getWeekDay() );
116  }
117 
118  bool TimeRange::isInSameRange( const DateTime& start,
119  const DateTime& end,
120  const DateTime& time1,
121  const DateTime& time2 )
122  {

◆ isInRange() [5/12]

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

Definition at line 130 of file TimeRange.h.

136  {

◆ isInRange() [6/12]

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

Definition at line 151 of file TimeRange.h.

155  :
156  static bool isInRange( const DateTime& start,
157  const DateTime& end,
158  const DateTime& time );
159 
160  static bool isInRange( const DateTime& startTime,
161  const DateTime& endTime,

◆ isInRange() [7/12]

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

Definition at line 138 of file TimeRange.h.

148  {
149  return isInSameRange

◆ isInRange() [8/12]

bool FIX::TimeRange::isInRange ( const LocalTimeStamp dateTime)
inline

Definition at line 236 of file TimeRange.h.

240  :
241  bool isInSameRange( const DateTime& time1, const DateTime& time2 )
242  {
243  if( m_startDay < 0 && m_endDay < 0 )
244  return isInSameRange( m_startTime, m_endTime, time1, time2 );
245  else

◆ isInRange() [9/12]

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

◆ isInRange() [10/12]

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

Definition at line 95 of file TimeRange.h.

102  {
103  return isInRange
104  ( (DateTime)start, (DateTime)end, (DateTime)time );
105  }

◆ isInRange() [11/12]

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

Definition at line 82 of file TimeRange.h.

92  {
93  return isInSameRange

◆ isInRange() [12/12]

bool FIX::TimeRange::isInRange ( const UtcTimeStamp dateTime)
inline

Definition at line 225 of file TimeRange.h.

229  {
230  if( !m_useLocalTime )
231  {
232  UtcTimeStamp utcTime1( time1.getTimeT() );
233  UtcTimeStamp utcTime2( time2.getTimeT() );
234  return isInSameRange( (DateTime)utcTime1, (DateTime)utcTime2 );

◆ isInSameRange() [1/9]

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

Definition at line 133 of file TimeRange.cpp.

136  {
137  int sessionLength = DateTime::SECONDS_PER_DAY - (start - end);
138 
139  if( time1 > time2 )
140  {
141  UtcTimeOnly time2TimeOnly = UtcTimeOnly(time2);
142 
143  long delta = time2TimeOnly - start;
144  if( delta < 0 )
145  delta = DateTime::SECONDS_PER_DAY - labs(delta);
146 
147  return (time1 - time2) < (sessionLength - delta);
148  }
149  else
150  {
151  return (time2 - time1) < sessionLength;
152  }
153  }
154  }
155 
156  bool TimeRange::isInSameRange( const DateTime& startTime,
157  const DateTime& endTime,
158  int startDay,
159  int endDay,
160  const DateTime& time1,
161  const DateTime& time2 )
162  {
163  if( !isInRange( startTime, endTime, startDay, endDay, time1, time1.getWeekDay() ) )
164  return false;
165 
166  if( !isInRange( startTime, endTime, startDay, endDay, time2, time2.getWeekDay() ) )
167  return false;
168 
169  int absoluteDay1 = time1.getJulianDate() - time1.getWeekDay();

◆ isInSameRange() [2/9]

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

Definition at line 171 of file TimeRange.cpp.

◆ isInSameRange() [3/9]

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

Definition at line 272 of file TimeRange.h.

◆ isInSameRange() [4/9]

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

Definition at line 163 of file TimeRange.h.

184  :

◆ isInSameRange() [5/9]

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

Definition at line 173 of file TimeRange.h.

184  :

◆ isInSameRange() [6/9]

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

Definition at line 259 of file TimeRange.h.

◆ isInSameRange() [7/9]

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

Definition at line 107 of file TimeRange.h.

113  {
114  return isInRange
115  ( (DateTime)startTime, (DateTime)endTime,

References isInRange().

Referenced by isInRange().

◆ isInSameRange() [8/9]

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

Definition at line 117 of file TimeRange.h.

125  {
126  return isInRange
127  ( (DateTime)startTime, (DateTime)endTime,
128  startDay, endDay,

◆ isInSameRange() [9/9]

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

Definition at line 247 of file TimeRange.h.

Member Data Documentation

◆ m_endDay

int FIX::TimeRange::m_endDay
private

Definition at line 284 of file TimeRange.h.

◆ m_endTime

UtcTimeOnly FIX::TimeRange::m_endTime
private

Definition at line 282 of file TimeRange.h.

Referenced by TimeRange().

◆ m_startDay

int FIX::TimeRange::m_startDay
private

Definition at line 283 of file TimeRange.h.

◆ m_startTime

UtcTimeOnly FIX::TimeRange::m_startTime
private

Definition at line 281 of file TimeRange.h.

Referenced by TimeRange().

◆ m_useLocalTime

bool FIX::TimeRange::m_useLocalTime
private

Definition at line 285 of file TimeRange.h.

Referenced by isInRange().


The documentation for this class was generated from the following files:
FIX::TimeRange::m_startTime
UtcTimeOnly m_startTime
Definition: TimeRange.h:281
FIX::TimeRange::m_startDay
int m_startDay
Definition: TimeRange.h:283
FIX::TYPE::UtcDate
Definition: FieldTypes.h:946
FIX::TYPE::UtcTimeStamp
Definition: FieldTypes.h:938
FIX::TimeRange::m_endDay
int m_endDay
Definition: TimeRange.h:284
FIX::TYPE::UtcTimeOnly
Definition: FieldTypes.h:948
FIX::TimeRange::m_endTime
UtcTimeOnly m_endTime
Definition: TimeRange.h:282
FIX::TimeRange::isInSameRange
static bool isInSameRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time1, const DateTime &time2)
Definition: TimeRange.h:107
FIX::TimeRange::m_useLocalTime
bool m_useLocalTime
Definition: TimeRange.h:285
FIX::TimeRange::isInRange
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:74
FIX::DateTime::SECONDS_PER_DAY
static const int64_t SECONDS_PER_DAY
Magic numbers.
Definition: FieldTypes.h:81

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2001