Menu

#42 UseLocalTime=Y does not work

pending
nobody
None
5
2012-03-07
2010-07-01
Scott
No

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.

Discussion

  • John Zwinck

    John Zwinck - 2010-08-02

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

     
  • Roman Shtylman

    Roman Shtylman - 2010-08-03

    Patch to work around this bug:

    diff --git a/src/C++/TimeRange.cpp b/src/C++/TimeRange.cpp
    index 474adff..0fa003d 100644
    --- a/src/C++/TimeRange.cpp
    +++ b/src/C++/TimeRange.cpp
    @@ -34,7 +34,8 @@ namespace FIX
    int startDay,
    int endDay )
    m_startTime( startTime ), m_endTime( endTime ),
    - m_startDay( startDay ), m_endDay( endDay )
    + m_startDay( startDay ), m_endDay( endDay ),
    + m_useLocalTime( false )
    {
    if( startDay > 0
    && endDay > 0
    @@ -48,7 +49,8 @@ namespace FIX
    int startDay,
    int endDay )
    m_startTime( startTime ), m_endTime( endTime ),
    - 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;
    };
    }

     
  • Roman Shtylman

    Roman Shtylman - 2010-08-04

    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.

     
  • Anonymous

    Anonymous - 2011-05-24

    Hi, I have the same problem, there are any progresses?

    Thank you.

     
  • Brian Crowell (Barbnet)

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

    diff --git a/src/C++/TimeRange.cpp b/src/C++/TimeRange.cpp
    index 474adff..0fa003d 100644
    --- a/src/C++/TimeRange.cpp
    +++ b/src/C++/TimeRange.cpp
    @@ -34,7 +34,8 @@ namespace FIX
    int startDay,
    int endDay )
    m_startTime( startTime ), m_endTime( endTime ),
    - m_startDay( startDay ), m_endDay( endDay )
    + m_startDay( startDay ), m_endDay( endDay ),
    + m_useLocalTime( false )
    {
    if( startDay > 0
    && endDay > 0
    @@ -48,7 +49,8 @@ namespace FIX
    int startDay,
    int endDay )
    m_startTime( startTime ), m_endTime( endTime ),
    - 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;
    };
    }

     
  • Oren Miller

    Oren Miller - 2012-03-07
    • status: open --> pending
     
  • Oren Miller

    Oren Miller - 2012-03-07

    Checked in a fix based on the newer patch.

     

Log in to post a comment.

Auth0 Logo