Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #31993
| Path | csiph.com!news.redatomik.org!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost2.xs4all.net!not-for-mail |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: What is wrong with this If Else construction? |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <47744619-426f-4af1-8376-e2935a2570db@googlegroups.com> <XnsA6EA6C0A11982eejj99@194.109.6.166> <2ee99c33-38ae-4097-b847-c3b7fc6ad63d@googlegroups.com> <XnsA6EADF22299AAeejj99@194.109.6.166> <XnsA6EAE239F6C95eejj99@194.109.6.166> <g5536cpnucefgic9328grcfd8dlehou0t7@4ax.com> |
| Date | Tue, 27 Dec 2016 00:02:41 +0100 |
| Message-ID | <XnsA6EB74D2CDEeejj99@194.109.6.166> (permalink) |
| User-Agent | Xnews/2009.05.01 |
| Lines | 61 |
| NNTP-Posting-Host | 77.174.145.5 |
| X-Trace | 1482793361 dreader36.news.xs4all.nl 1740 ehannivo/77.174.145.5:49607 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.javascript:31993 |
Show key headers only | View raw
Gene Wirchenko <genew@telus.net> wrote on 26 Dec 2016 in
comp.lang.javascript:
> On Mon, 26 Dec 2016 22:14:20 +0100, "Evertjan."
> <exxjxw.hannivoort@inter.nl.net> wrote:
>
> [snip]
>
>>btw, if you still want to use VBS,
>>consider this [entering now, when still alive]:
>>
>>function age(born,died)
>> age = DateDiff("yyyy", born, died) +
>> (died < DateSerial(Year(died), Month(born), Day(born)))
>>end function
>
> I do not know DateSerial(), but this code has a possible smell of
> not handling a leap year correctly. What happens if the person was
> born on Leap Day and dies in a non-leap year? (Will DateSerial()
> throw an error or otherwise malfunction?
Why, oh why don't you test this for yourself?
It is so easy:
<%
function age(born,died)
age = DateDiff("yyyy", born, died) +_
(died < DateSerial(Year(died), Month(born), Day(born)))
end function
born = #2004/02/29#
died = #2005/02/28#
response.write age(born, died) ' 0
born = #2004/02/28#
died = #2005/02/28#
response.write age(born, died) ' 1
born = #2004/02/29#
died = #2005/03/01#
response.write age(born, died) ' 1
born = #2003/02/28#
died = #2004/02/29#
response.write age(born, died) ' 1
born = #1999/02/28#
died = #2000/02/29#
response.write age(born, died) ' 1
' error as expected: died = #2100/02/29#
%>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What is wrong with this If Else construction? bart.smissaert@gmail.com - 2016-12-26 00:05 -0800
Re: What is wrong with this If Else construction? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-26 10:37 +0100
Re: What is wrong with this If Else construction? bart.smissaert@gmail.com - 2016-12-26 03:45 -0800
Re: What is wrong with this If Else construction? Luuk <luuk@invalid.lan> - 2016-12-26 12:59 +0100
Re: What is wrong with this If Else construction? bart.smissaert@gmail.com - 2016-12-26 04:02 -0800
Re: What is wrong with this If Else construction? bart.smissaert@gmail.com - 2016-12-26 04:16 -0800
Re: What is wrong with this If Else construction? me <mu@local.local> - 2016-12-26 13:34 +0100
Re: What is wrong with this If Else construction? Bart Smissaert <bart.smissaert@gmail.com> - 2016-12-26 05:02 -0800
Re: What is wrong with this If Else construction? Luuk <luuk@invalid.lan> - 2016-12-26 18:32 +0100
Re: What is wrong with this If Else construction? Bart Smissaert <bart.smissaert@gmail.com> - 2016-12-26 15:32 -0800
Re: What is wrong with this If Else construction? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-27 10:05 +0100
Re: What is wrong with this If Else construction? Bart Smissaert <bart.smissaert@gmail.com> - 2016-12-27 03:27 -0800
Re: What is wrong with this If Else construction? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-27 21:46 +0100
Re: What is wrong with this If Else construction? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-29 18:36 +0100
Re: What is wrong with this If Else construction? Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-12-28 23:16 +0000
Re: What is wrong with this If Else construction? Luuk <luuk@invalid.lan> - 2016-12-27 22:28 +0100
Re: What is wrong with this If Else construction? Gene Wirchenko <genew@telus.net> - 2016-12-27 15:07 -0800
Re: What is wrong with this If Else construction? Luuk <luuk@invalid.lan> - 2016-12-28 19:37 +0100
Re: What is wrong with this If Else construction? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-26 21:56 +0100
Re: What is wrong with this If Else construction? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-26 22:14 +0100
Re: What is wrong with this If Else construction? Gene Wirchenko <genew@telus.net> - 2016-12-26 14:12 -0800
Re: What is wrong with this If Else construction? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-27 00:02 +0100
Re: What is wrong with this If Else construction? Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-12-27 22:36 +0000
Re: What is wrong with this If Else construction? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-28 10:36 +0100
Re: What is wrong with this If Else construction? Luuk <luuk@invalid.lan> - 2016-12-26 17:00 +0100
OT: Leap year bug in Excel (was: What is wrong with this If Else construction?) "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-12-26 17:12 +0100
Re: What is wrong with this If Else construction? Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-12-27 22:52 +0000
Re: What is wrong with this If Else construction? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-12-28 01:01 +0100
Re: What is wrong with this If Else construction? $Bill <news@todbe.com> - 2016-12-27 22:19 -0800
Re: What is wrong with this If Else construction? Tim Streater <timstreater@greenbee.net> - 2016-12-28 10:05 +0000
Re: What is wrong with this If Else construction? [OT] $Bill <news@todbe.com> - 2016-12-28 13:59 -0800
Re: What is wrong with this If Else construction? [OT] Tim Streater <timstreater@greenbee.net> - 2016-12-28 22:17 +0000
csiph-web