[Quickfix-developers] Re: UtcTimeStamp implementation bugs
Brought to you by:
orenmnero
|
From: Caleb E. <cal...@gm...> - 2005-07-13 23:11:29
|
Ok, as threatened, here is the patch.
This patch replaces the underlying implementation of the UtcTimeStamp,
UtcDateOnly and UtcTimeOnly classes with a new class called DateTime.
The impetus for this is to fix potential daylight savings time bugs in
the previous implementation and reduce the dependence on the system
calls mktime() and localtime(), which are real performance pigs on
some platforms (e.g. all versions of SunOS and Solaris prior to
Solaris 9).
The new DateTime class uses two integers to represent a point in time.
One stores a Julian day number and the other stores a number of
milliseconds since midnight. This implementation uses far less memory
than its predecessor (8 bytes instead of 44 for struct tm on Linux),
allows the use of a much wider range of dates (no 2038 problem) and is
faster to boot.
I have tested this patch on Linux only so far, but it passes all user-
and acceptance-tests. I don't have MySQL available to test the
changes to the MySQLStore and MySQLLog classes.
Detailed changes:
Field.h: make getValue and type conversion operators return non-const
values. Returning const temporaries makes no sense.
FieldConvertors.h: use compound getYMD/getHMS to extract values. Use
public methods to initialize Utc{TimeStamp,DateOnly,TimeOnly}, not
static_cast. Don't create default-constructed variables (which hit
the system clock).
FieldTypes.cpp: removed UtcTimeStamp::setTime, ::operator+=3D. Added
DateTime::now here. Because this code is compiled into the library,
HAVE_FTIME no longer needs to be defined to create timestamps with
millisecond resolution (this closes several bugs in the bug tracker).=20
We try to use gettimeofday if HAVE_FTIME is not defined (we should
probably check for gettimeofday first - ftime is deprecated).
FieldTypes.h: added DateTime class. Modified Utc* classes to inherit
from it. Dropped namespace-global constant UTC_DAY. Use enum values
from DateTime instead.
MySQLLog.cpp, MySQLStore.cpp: use public interface to UtcTimeStamp,
not casting. UNTESTED.
tests:
FieldConvertorsTestCase.cpp: use aggregate setYMD/setHMS methods.
getYearDay went away (this is the only place it was ever used)
MessagesTestCase.cpp: 1900-01-00 is not a valid date. Use 1900-01-01.
SessionTestCase.cpp, UtcTimeStampTestCase.cpp: Use DateTime::SECONDS_PER_DA=
Y
--=20
Caleb Epstein
caleb dot epstein at gmail dot com
|