Results 1 to 40 of 93

Thread: Calculating exact time in Years, MOnths, Days

Threaded View

  1. #30
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Calculating exact time in Years, MOnths, Days

    Quote Originally Posted by Sitten Spynne View Post
    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.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

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
  •  



Click Here to Expand Forum to Full Width