UseLocalTime=Y does not work
Brought to you by:
orenmnero
How to reproduce:
Set the StartTime and EndTime to a value such that right now Quickfix should be enabled if these are interpreted as LocalTime, but not if these are interpreted as UTC time. Set UseLocalTime=Y. Try to start the initiator.
I believe it also affects the acceptor.
You can also check it by choosing a time such that the connection would work if interpreted as UTC, and not work if interpreted as LocalTime, and see that the connection does in fact work.
I have the same problem. I tend to think it was caused by rev. 2160 to TimeRange,
<a href="http://quickfix.svn.sourceforge.net/viewvc/quickfix/trunk/quickfix/src/C%2B%2B/TimeRange.h?r1=2160&r2=2159&pathrev=2160">here</a>.
Patch to work around this bug:
- m_startDay( startDay ), m_endDay( endDay )
+ m_startDay( startDay ), m_endDay( endDay ),
+ m_useLocalTime( true )
{
if( startDay > 0
&& endDay > 0
diff --git a/src/C++/TimeRange.h b/src/C++/TimeRange.h
index 8e781b0..746ca2e 100644
--- a/src/C++/TimeRange.h
+++ b/src/C++/TimeRange.h
@@ -160,11 +160,19 @@ public:
bool isInSameRange( const UtcTimeStamp& time1, const UtcTimeStamp& time2 )
{
+ if ( m_useLocalTime )
+ return isInSameRange(
+ DateTime::fromLocalTimeT( time1.getTimeT() ),
+ DateTime::fromLocalTimeT( time2.getTimeT() ));
return isInSameRange( (DateTime)time1, (DateTime)time2 );
}
bool isInSameRange( const LocalTimeStamp& time1, const LocalTimeStamp& time2 )
{
+ if ( !m_useLocalTime )
+ return isInSameRange(
+ DateTime::fromUtcTimeT( time1.getTimeT() ),
+ DateTime::fromUtcTimeT( time2.getTimeT() ));
return isInSameRange( (DateTime)time1, (DateTime)time2 );
}
@@ -182,6 +190,7 @@ private:
UtcTimeOnly m_endTime;
int m_startDay;
int m_endDay;
+ bool m_useLocalTime;
};
}
Correction. The patch below doesn't work. While there is no error that says the login time is outside the range, the quickfix initiator seems to hang, neither logging in or out.
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Hi, I have the same problem, there are any progresses?
Thank you.
I have a patch. It's similar to the August 2010 one below, but I think this one covers all the bases. It adds m_useLocalTime back to TimeRange (why that was ever removed, I don't know), but drops the LocalTimeStamp version of isInSameRange, since every caller is using UTC anyways.
I want to attach it, but I can't. I'll copy and paste it here, then post it as an attachment to the mailing list.
diff --git a/src/C++/Session.h b/src/C++/Session.h
index 7235d5f..a44cc5d 100644
--- a/src/C++/Session.h
+++ b/src/C++/Session.h
@@ -105,9 +105,9 @@ public:
static int numSessions();
- bool isSessionTime(const DateTime& time)
+ bool isSessionTime(const UtcTimeStamp& time)
{ return m_sessionTime.isInRange(time); }
- bool isLogonTime(const DateTime& time)
+ bool isLogonTime(const UtcTimeStamp& time)
{ return m_logonTime.isInRange(time); }
bool isInitiator()
{ return m_state.initiate(); }
diff --git a/src/C++/SessionFactory.cpp b/src/C++/SessionFactory.cpp
index 76de8f4..2ec451f 100644
--- a/src/C++/SessionFactory.cpp
+++ b/src/C++/SessionFactory.cpp
@@ -166,9 +166,9 @@ Session* SessionFactory::create( const SessionID& sessionID,
logonDay, logoutDay );
TimeRange logonTimeRange = useLocalTime ? localLogonTime : utcLogonTime;
- if( !sessionTimeRange.isInRange(logonTime) )
+ if( !sessionTimeRange.isInRange(startTime, endTime, logonTime) )
throw ConfigError( "LogonTime must be between StartTime and EndTime" );
- if( !sessionTimeRange.isInRange(logoutTime) )
+ if( !sessionTimeRange.isInRange(startTime, endTime, logoutTime) )
throw ConfigError( "LogoutTime must be between StartTime and EndTime" );
pSession->setLogonTime( logonTimeRange );
- m_startDay( startDay ), m_endDay( endDay )
+ m_startDay( startDay ), m_endDay( endDay ),
+ m_useLocalTime( true )
{
if( startDay > 0
&& endDay > 0
diff --git a/src/C++/TimeRange.h b/src/C++/TimeRange.h
index 8e781b0..bce5de4 100644
--- a/src/C++/TimeRange.h
+++ b/src/C++/TimeRange.h
@@ -149,22 +149,26 @@ private:
const DateTime& time1,
const DateTime& time2 );
public:
- bool isInRange( const DateTime& dateTime )
+ bool isInRange( const UtcTimeStamp& dateTime )
{
+ LocalTimeStamp localTime( dateTime.getTimeT() );
+ DateTime &compareTime = m_useLocalTime ? (DateTime&) localTime : (DateTime&) dateTime;
+
if( m_startDay < 0 && m_endDay < 0 )
- return isInRange( m_startTime, m_endTime, dateTime );
+ return isInRange( m_startTime, m_endTime, compareTime );
else
return isInRange
- ( m_startTime, m_endTime, m_startDay, m_endDay, dateTime );
+ ( m_startTime, m_endTime, m_startDay, m_endDay, compareTime );
}
bool isInSameRange( const UtcTimeStamp& time1, const UtcTimeStamp& time2 )
{
- return isInSameRange( (DateTime)time1, (DateTime)time2 );
- }
+ if( m_useLocalTime )
+ {
+ LocalTimeStamp time1Local( time1.getTimeT() ), time2Local( time2.getTimeT() );
+ return isInSameRange( (DateTime) time1Local, (DateTime) time2Local );
+ }
- bool isInSameRange( const LocalTimeStamp& time1, const LocalTimeStamp& time2 )
- {
return isInSameRange( (DateTime)time1, (DateTime)time2 );
}
@@ -182,6 +186,7 @@ private:
UtcTimeOnly m_endTime;
int m_startDay;
int m_endDay;
+ bool m_useLocalTime;
};
}
Checked in a fix based on the newer patch.