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 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.

References m_endTime, and m_startTime.

35  : m_startTime( startTime ), m_endTime( endTime ),
36  m_startDay( startDay ), m_endDay( endDay ),
37  m_useLocalTime( false )
38  {
39  if( startDay > 0
40  && endDay > 0
41  && startDay == endDay
42  && endTime > startTime )
43  { m_endTime = m_startTime; }
44  }
UtcTimeOnly m_endTime
Definition: TimeRange.h:251
bool m_useLocalTime
Definition: TimeRange.h:254
UtcTimeOnly m_startTime
Definition: TimeRange.h:250

◆ 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.

References m_endTime, and m_startTime.

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  }
UtcTimeOnly m_endTime
Definition: TimeRange.h:251
bool m_useLocalTime
Definition: TimeRange.h:254
UtcTimeOnly m_startTime
Definition: TimeRange.h:250

Member Function Documentation

◆ isInRange() [1/12]

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

Definition at line 43 of file TimeRange.h.

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

46  {
47  return isInRange
48  ( (DateTime)start, (DateTime)end, (DateTime)time );
49  }
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

◆ isInRange() [2/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 51 of file TimeRange.h.

References isInRange().

57  {
58  return isInRange
59  ( (DateTime)startTime, (DateTime)endTime,
60  startDay, endDay,
61  (DateTime)time, day );
62  }
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

◆ isInRange() [3/12]

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

Definition at line 64 of file TimeRange.h.

References isInRange().

69  {
70  return isInRange
71  ( (DateTime)startTime, (DateTime)endTime,
72  startDay, endDay,
73  (DateTime)time );
74  }
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

◆ isInRange() [4/12]

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

Definition at line 99 of file TimeRange.h.

References isInRange().

102  {
103  return isInRange
104  ( (DateTime)start, (DateTime)end, (DateTime)time );
105  }
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

◆ isInRange() [5/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 107 of file TimeRange.h.

References isInRange().

113  {
114  return isInRange
115  ( (DateTime)startTime, (DateTime)endTime,
116  startDay, endDay,
117  (DateTime)time, day );
118  }
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

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

References isInRange().

125  {
126  return isInRange
127  ( (DateTime)startTime, (DateTime)endTime,
128  startDay, endDay,
129  (DateTime)time );
130  }
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

◆ isInRange() [7/12]

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

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  }

◆ isInRange() [8/12]

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

Definition at line 73 of file TimeRange.cpp.

References isInRange().

79  {
80  UtcTimeOnly timeOnly (time);
81 
82  if( startDay == endDay )
83  {
84  if( day != startDay )
85  return true;
86  return isInRange( startTime, endTime, time );
87  }
88  else if( startDay < endDay )
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  }
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

◆ isInRange() [9/12]

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

Definition at line 109 of file TimeRange.cpp.

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

114  {
115  return isInRange( startTime, endTime, startDay, endDay, time, time.getWeekDay() );
116  }
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

◆ isInRange() [10/12]

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

Definition at line 185 of file TimeRange.h.

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

186  {
187  if( m_startDay < 0 && m_endDay < 0 )
188  return isInRange( m_startTime, m_endTime, dateTime );
189  else
190  return isInRange
191  ( m_startTime, m_endTime, m_startDay, m_endDay, dateTime, day );
192  }
UtcTimeOnly m_endTime
Definition: TimeRange.h:251
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43
UtcTimeOnly m_startTime
Definition: TimeRange.h:250

◆ isInRange() [11/12]

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

Definition at line 194 of file TimeRange.h.

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

195  {
196  if( m_useLocalTime )
197  {
198  LocalTimeStamp localDateTime( dateTime.getTimeT() );
199  return isInRange( localDateTime, localDateTime.getWeekDay() );
200  }
201 
202  return isInRange( dateTime, dateTime.getWeekDay() );
203  }
bool m_useLocalTime
Definition: TimeRange.h:254
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

◆ isInRange() [12/12]

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

Definition at line 205 of file TimeRange.h.

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

206  {
207  if( !m_useLocalTime )
208  {
209  LocalTimeStamp utcDateTime( dateTime.getTimeT() );
210  return isInRange( utcDateTime, utcDateTime.getWeekDay() );
211  }
212 
213  return isInRange( dateTime, dateTime.getWeekDay() );
214  }
bool m_useLocalTime
Definition: TimeRange.h:254
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

◆ isInSameRange() [1/9]

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

Definition at line 76 of file TimeRange.h.

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

80  {
81  return isInSameRange
82  ( (DateTime)start, (DateTime)end,
83  (DateTime)time1, (DateTime)time2 );
84  }
static bool isInSameRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time1, const DateTime &time2)
Definition: TimeRange.h:76

◆ isInSameRange() [2/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 86 of file TimeRange.h.

References isInSameRange().

92  {
93  return isInSameRange
94  ( (DateTime)startTime, (DateTime)endTime,
95  startDay, endDay,
96  (DateTime)time1, (DateTime)time2 );
97  }
static bool isInSameRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time1, const DateTime &time2)
Definition: TimeRange.h:76

◆ isInSameRange() [3/9]

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

Definition at line 132 of file TimeRange.h.

References isInSameRange().

136  {
137  return isInSameRange
138  ( (DateTime)start, (DateTime)end,
139  (DateTime)time1, (DateTime)time2 );
140  }
static bool isInSameRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time1, const DateTime &time2)
Definition: TimeRange.h:76

◆ isInSameRange() [4/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 142 of file TimeRange.h.

References isInRange(), and isInSameRange().

148  {
149  return isInSameRange
150  ( (DateTime)startTime, (DateTime)endTime,
151  startDay, endDay,
152  (DateTime)time1, (DateTime)time2 );
153  }
static bool isInSameRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time1, const DateTime &time2)
Definition: TimeRange.h:76

◆ isInSameRange() [5/9]

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

Definition at line 118 of file TimeRange.cpp.

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

122  {
123  if( !isInRange( start, end, time1 ) ) return false;
124  if( !isInRange( start, end, time2 ) ) return false;
125 
126  if( time1 == time2 ) return true;
127 
128  if( start < end || start == end )
129  {
130  UtcDate time1Date( time1 );
131  UtcDate time2Date( time2 );
132 
133  return time1Date == time2Date;
134  }
135  else
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  }
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43
static const int64_t SECONDS_PER_DAY
Magic numbers.
Definition: FieldTypes.h:66

◆ isInSameRange() [6/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 156 of file TimeRange.cpp.

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

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();
170  int absoluteDay2 = time2.getJulianDate() - time2.getWeekDay();
171  return absoluteDay1 == absoluteDay2;
172  }
static bool isInRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time)
Definition: TimeRange.h:43

◆ isInSameRange() [7/9]

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

Definition at line 216 of file TimeRange.h.

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

217  {
218  if( m_useLocalTime )
219  {
220  LocalTimeStamp localTime1( time1.getTimeT() );
221  LocalTimeStamp localTime2( time2.getTimeT() );
222  return isInSameRange( (DateTime)localTime1, (DateTime)localTime2 );
223  }
224 
225  return isInSameRange( (DateTime)time1, (DateTime)time2 );
226  }
bool m_useLocalTime
Definition: TimeRange.h:254
static bool isInSameRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time1, const DateTime &time2)
Definition: TimeRange.h:76

◆ isInSameRange() [8/9]

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

Definition at line 228 of file TimeRange.h.

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

229  {
230  if( !m_useLocalTime )
231  {
232  UtcTimeStamp utcTime1( time1.getTimeT() );
233  UtcTimeStamp utcTime2( time2.getTimeT() );
234  return isInSameRange( (DateTime)utcTime1, (DateTime)utcTime2 );
235  }
236 
237  return isInSameRange( (DateTime)time1, (DateTime)time2 );
238  }
bool m_useLocalTime
Definition: TimeRange.h:254
static bool isInSameRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time1, const DateTime &time2)
Definition: TimeRange.h:76

◆ isInSameRange() [9/9]

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

Definition at line 241 of file TimeRange.h.

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

242  {
243  if( m_startDay < 0 && m_endDay < 0 )
244  return isInSameRange( m_startTime, m_endTime, time1, time2 );
245  else
246  return isInSameRange
247  ( m_startTime, m_endTime, m_startDay, m_endDay, time1, time2 );
248  }
UtcTimeOnly m_endTime
Definition: TimeRange.h:251
UtcTimeOnly m_startTime
Definition: TimeRange.h:250
static bool isInSameRange(const UtcTimeOnly &start, const UtcTimeOnly &end, const DateTime &time1, const DateTime &time2)
Definition: TimeRange.h:76

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(), 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(), and TimeRange().

◆ m_useLocalTime

bool FIX::TimeRange::m_useLocalTime
private

Definition at line 254 of file TimeRange.h.

Referenced by isInRange(), and isInSameRange().


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

Generated on Sun Apr 15 2018 21:44:06 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001