If you really aren't happy with the
TimeSpan[
^] object, then you probably want something like:
Public Sub NaturalLength(length As Integer, ByRef years As Integer, ByRef months As Integer, ByRef days As Integer)
Dim remain As Double
Dim amount As Double
remain = CType(length, Double)
amount = remain / 365.25
years = Math.Truncate(amount)
remain = remain - years * 365.25
amount = remain / 30.4375
months = Math.Truncate(amount)
remain = remain - months * 30.4375
days = Math.Truncate(remain)
End Sub
Sub Main()
Dim length As Integer = 396
Dim y, m, d As Integer
NaturalLength(length, y, m, d)
Console.WriteLine("Years: {0}, months: {0}, days = {0}", y, m, d)
End Sub
By the way:
Quote:
for example average = 396 my result should be 1 year, 1month and 6days
looks wrong to me.