[Mono-list] Porting a spreadsheet to C#
Paul F. Johnson
paul at all-the-johnsons.co.uk
Sun Aug 28 13:49:04 EDT 2011
Hi,
I'm almost done porting a time of death calculator based on the Henssge
Monogram spreadsheet[1].
I've got just about all of it done, but am having a shed load of
problems with the final step - the final calculation. The code I have so
far for the calculation is this
private void calctod(DateTime death)
{
DateTime newdeath = death;
double ta = Convert.ToDouble(surroundtemp.Text);
double tr = Convert.ToDouble(bodytemp.Text);
double m = Convert.ToDouble(weight.Text);
double factor;
bool t = ta <= 23 ? true : false;
calculateCandB(ta, tr, m);
calculateCorrections(t);
calculateIterations(t);
factor = correctionfactor();
double h, mi;
h = (-cas * factor);
mi = -(((cas - Convert.ToInt32(cas)) * 100) / 1.6666) *
factor + h;
newdeath.AddHours(h).AddMinutes(mi);
TimeSpan calced = death.Subtract(newdeath);
DateTime todead = death.Subtract(calced);
tod(todead.TimeOfDay.ToString(),
todead.Date.ToShortDateString());
}
The numbers being returned from the calculate methods are giving me the
same result as I get from the spreadsheet, so they're fine.
The problem seems to be in trying to parse the Excel =TIME for the time
of death. The calculations for mi is a literal conversion of the =TIME
equation.
Can anyone shed any light on where I'm going wrong as this is driving me
somewhat insane!
Thanks
Paul
[1] www.all-the-johnsons.co.uk/tod/henssge.xls
[2] www.all-the-johnsons.co.uk/tod/Henssge.zip <- source code
--
Vertraue mir, ich weiss, was ich mache...
More information about the Mono-list
mailing list