[Mono-list] Porting a spreadsheet to C#

Ian Norton inb at ncipher.com
Sun Aug 28 14:14:07 EDT 2011


What format is the date text in?
-- 
I may have used dictation software to write this email, please excuse any confusing mistakes.

"Paul F. Johnson" <paul at all-the-johnsons.co.uk> wrote:

>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...
>
>_______________________________________________
>Mono-list maillist  -  Mono-list at lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-list



More information about the Mono-list mailing list