Re: [Quickfix-developers] Re: WeeklySession patch, getWeekDay() patch
Brought to you by:
orenmnero
|
From: Oren M. <or...@qu...> - 2005-10-19 14:58:32
|
Caleb,
I'd be happy to make you a commiter. Just send me your account id for =
your sourceforge account.
--oren
----- Original Message -----=20
From: Caleb Epstein=20
To: or...@qu... ; =
qui...@li...=20
Sent: Wednesday, October 19, 2005 8:03 AM
Subject: [Quickfix-developers] Re: WeeklySession patch, getWeekDay() =
patch
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 proper 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 compensate 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.h please. 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);
}
=20
/// Convert the DateTime to a time_t. Note that this operation
--=20
Caleb Epstein
caleb dot epstein at gmail dot com |