Age Calculator
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Age Calculator
Has anyone come up with a way to determine the age and month of a person if given a date line 02/22/1877?
-
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Age Calculator
Well, I hadn't until I saw your post!
Nothing like THAT on a Sunday to whet my teeth.
I'm a sadistic "tiddly-pom" so I'll leave you to convert the seconds back into DAYS and YEARS.
Nothing like THAT on a Sunday to whet my teeth.
I'm a sadistic "tiddly-pom" so I'll leave you to convert the seconds back into DAYS and YEARS.
Re: Age Calculator
Where is the Months then?richmond62 wrote:I'm a sadistic "tiddly-pom" so I'll leave you to convert the seconds back into DAYS and YEARS.
-
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Age Calculator
Awesome richmond, just pure awesome
Re: Age Calculator
Richmond,
Im impressed you were able to refer back to an old Hypercard book. Thanks, Max
Im impressed you were able to refer back to an old Hypercard book. Thanks, Max
Re: Age Calculator
just divide by 31536000 to get the age.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Age Calculator
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
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
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Age Calculator
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
viewtopic.php?f=9&t=26619&p=138530&hili ... ng#p138530
Craig
-
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Age Calculator
At 55, I'm a bit of an old book . . . and perpetually fighting with my wife who wants to chuck thingsIm impressed you were able to refer back to an old Hypercard book.
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
Re: Age Calculator
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
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
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Age Calculator
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
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
shiftLock happens
Re: Age Calculator
Thanks Hermann, I already know and use Malte's library.
I just find it incredible that something so fundamental is not being addressed natively.
I just find it incredible that something so fundamental is not being addressed natively.
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Age Calculator
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):
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
shiftLock happens