Page 1 of 1

Age Calculator

Posted: Sun Aug 13, 2017 2:50 am
by maxs
Has anyone come up with a way to determine the age and month of a person if given a date line 02/22/1877?

Re: Age Calculator

Posted: Sun Aug 13, 2017 10:43 am
by richmond62
Well, I hadn't until I saw your post!

Nothing like THAT on a Sunday to whet my teeth.
HD.jpg
HOT DATE.livecode.zip
Here's the stack
(92.16 KiB) Downloaded 95 times
I'm a sadistic "tiddly-pom" so I'll leave you to convert the seconds back into DAYS and YEARS.

Re: Age Calculator

Posted: Sun Aug 13, 2017 2:13 pm
by bogs
richmond62 wrote:I'm a sadistic "tiddly-pom" so I'll leave you to convert the seconds back into DAYS and YEARS.
Where is the Months then? :P

Re: Age Calculator

Posted: Sun Aug 13, 2017 3:36 pm
by richmond62
DGHD372.jpg
DGHD373.jpg

Re: Age Calculator

Posted: Sun Aug 13, 2017 4:04 pm
by bogs
Awesome richmond, just pure awesome :lol:

Re: Age Calculator

Posted: Sun Aug 13, 2017 4:15 pm
by maxs
Richmond,

Im impressed you were able to refer back to an old Hypercard book. Thanks, Max

Re: Age Calculator

Posted: Sun Aug 13, 2017 4:32 pm
by maxs
just divide by 31536000 to get the age.

Re: Age Calculator

Posted: Sun Aug 13, 2017 4:46 pm
by jmburnod
Hi,
I'm afraid that is a little more complicate.
@Max
Are you sure that it works with a date < 1/1/1970 (as first post 1877)
Best regards
Jean-Marc

Re: Age Calculator

Posted: Sun Aug 13, 2017 4:58 pm
by dunbarx
It may be useful to read the thread "When was the Big Bang" to get old, old dates. 1877 is a no-brainer. The Jurassic era requires extra coding.

viewtopic.php?f=9&t=26619&p=138530&hili ... ng#p138530

Craig

Re: Age Calculator

Posted: Sun Aug 13, 2017 5:23 pm
by richmond62
Im impressed you were able to refer back to an old Hypercard book.
At 55, I'm a bit of an old book . . . and perpetually fighting with my wife who wants to chuck things
out all the time.

She "went a bit funny" when I managed to retrieve a whole 5 years worth of her academic work she thought was lost forever from a
load of ZIP disks . . . which I read through a SCSI ZIP drive connected to a SCSI PCI card connected to a machine running Ubuntu Linux.

No more fights :wink:

Re: Age Calculator

Posted: Sun Aug 13, 2017 5:23 pm
by jmburnod
Finally, big bang was a sunday :D

Re: Age Calculator

Posted: Sun Aug 13, 2017 6:49 pm
by SparkOut
On Windows,1877 is not a date. Nothing existed before 1970.

http://quality.livecode.com/show_bug.cgi?id=4941


To me, this is the single most inexplicable (that it has not been addressed in all this time, and that I seem to be in a very small minority with this opinion), serious and unacceptable thing in the qcc

Re: Age Calculator

Posted: Mon Aug 14, 2017 10:35 am
by [-hh]
You could use Malte's libdate, see his announcement here:
viewtopic.php?p=123544#p123544

For the age in number of days see the second box at right of his demo stack from github
https://github.com/derbrill/libdate

Re: Age Calculator

Posted: Mon Aug 14, 2017 1:48 pm
by SparkOut
Thanks Hermann, I already know and use Malte's library.
I just find it incredible that something so fundamental is not being addressed natively.

Re: Age Calculator

Posted: Mon Aug 14, 2017 5:00 pm
by [-hh]
My link was for the OP's question, not for you! How can you assume that?!

Of course you are right with your opinion about tdate and time on Win, but don't forget, that LC goes even 10 years back before the birth date of DOS ;-)

p.s.
I read the OP's question again, thoroughly. He doesn't need any date or time lib, as he is asking for years and months only, not for days or seconds.
So we have only 2 to 4 'direct' additions/subtractions and 2 comparisons to get the result (here 140 years and 5 months):

Code: Select all

on mouseUp
  answer yearsAndMonth(1877,02,22,2017,08,14) 
end mouseUp

function yearsAndMonth y1,m1,d1,y2,m2,d2
  put y2-y1 into y; put m2-m1 into m
  if d2 < d1 then subtract 1 from m
  if m<0 then
    subtract 1 from y; add 12 to m
  end if
  return y & " years and " & m & "months"
end yearsAndMonth