|
-
Jul 27th, 2011, 11:01 AM
#30
Re: Calculating exact time in Years, MOnths, Days
 Originally Posted by Sitten Spynne
You might want to rethink that.
In other news, brute force fell flat. In order for my technique to work, you have to have a way to calculate the "expected" range. Calculating the expected range is what the algorithm is trying to do; you can't test something with itself. I'm not sure I trust #58 either; all you're doing is testing one algorithm for calculating the range against another. Rats.
Haven't spent much time on the revised #2; I can't figure out which pieces are important and which pieces aren't. I'll wait until you've got something presentable while I ruminate on the test cases.
1/29/2005 does (did) exist.
Read #42 to see why I think #58 works.
Here is a simple example of how to use the code in #2
Code:
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
Try
Dim foo As New AgeCalc(Date.Parse(TextBox1.Text), Date.Parse(TextBox2.Text))
Dim bar As Age = foo.AgeInYearsMonthsDays
Label1.Text = bar.Years.ToString & " " & bar.Months.ToString & " " & bar.Days.ToString
Catch ex As Exception
End Try
End Sub
Try these date pairs for controversy:
1/30/2005 - 4/30/2005
1/31/2005 - 4/30/2005
Last edited by dbasnett; Jul 27th, 2011 at 11:38 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|