[Quickfix-developers] UtcTimeStamp additions / tests
Brought to you by:
orenmnero
From: Brian E. <Br...@ma...> - 2003-11-04 20:51:08
|
Recently I've found a need to use the tm_yday member in the struct tm, used by the UtcTimeStamp class. The strptime.c does not calculate or clear this member. I've added this code at the bottom of strptime.c to calcuate this value: char isLeapYear; int mon,year; ... // Fix up yday field year = tm->tm_year + 1900; isLeapYear = (year%4==0) - (year%100==0) + (year%400==0) - (year%4000==0); mon = tm->tm_mon; // 0 == January tm->tm_yday = (mon>0)*31 + // Jan (mon>1)*(28+isLeapYear) + // Feb (mon>2)*31 + // March (mon>3)*30 + // April (mon>4)*31 + // May (mon>5)*30 + // June (mon>6)*31 + // July (mon>7)*31 + // Aug (mon>8)*30 + // Sept (mon>9)*31 + // Oct (mon>10)*30 + // Nov + tm->tm_mday - 1; In FieldType.h, I've added to the UtcTimeStamp class: int getYday() const { return tm_yday + 1; } and to the UtcDate class: int getYday() const { return UtcTimeStamp::getYday(); } I've added two test cases to FieldConvertsTestCase.cpp: void FieldConvertorsTestCase::utcTimeStampConvertFrom::onRun( void*& ) { ... assert( result.getYday() == 117 ); } void FieldConvertorsTestCase::utcDateConvertFrom::onRun( void*& ) { ... assert( result.getYday() == 117 ); } I was not able to contact the author of strptime.c to submit this addition. |