[Quickfix-developers] Re: WeeklySession patch, getWeekDay() patch
Brought to you by:
orenmnero
|
From: Caleb E. <cal...@gm...> - 2005-10-19 13:04:16
|
On 10/3/05, Caleb Epstein <cal...@gm...> wrote: > The problem with my original implementation is that I cribbed the formula > from http://scienceworld.wolfram.com/astronomy/Weekday.html without prope= r > testing. The definition of "mod" in this context doesn't match C/C++ > operator%. A mod B in terms of that equation should always have the same > sign as B (B =3D=3D 7, so the result must be positive), so we need to com= pensate > when the calculation goes negative. Attached is a patch that fixes this > error. > Oren, this fix is still not in CVS. Can you apply the patch to FieldTypes.hplease. I don't have write access to CVS - maybe I could be made a committer? Index: FieldTypes.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/quickfix/quickfix/src/C++/FieldTypes.h,v retrieving revision 1.21 diff -u -b -r1.21 FieldTypes.h --- FieldTypes.h 17 Jul 2005 19:27:06 -0000 1.21 +++ FieldTypes.h 19 Oct 2005 13:00:57 -0000 @@ -161,9 +161,10 @@ int m =3D M >=3D 3 ? M - 2 : M + 10; int Yprime =3D M >=3D 3 ? Y : Y - 1; int y =3D Yprime % 100; - int c =3D int (Yprime / 100); - return 1 + (D + int (2.6 * m - 0.2) + y + int (y / 4) + int (c / 4) - + int c =3D Yprime / 100; + int wd =3D (D + int (2.6 * m - 0.2) + y + int (y / 4) + int (c / 4) - (2 * c)) % 7; + return 1 + (wd < 0 ? 7 + wd : wd); } /// Convert the DateTime to a time_t. Note that this operation -- Caleb Epstein caleb dot epstein at gmail dot com |