Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32021

Re: What is wrong with this If Else construction?

Newsgroups comp.lang.javascript
Subject Re: What is wrong with this If Else construction?
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References (6 earlier) <f7217774-4e2d-49e6-b03b-a21aec7980b1@googlegroups.com> <XnsA6EB66B6EE392eejj99@194.109.6.166> <505046fc-12c8-4dcc-8ae6-c3caf7470b1a@googlegroups.com> <XnsA6EBDD7D05C4Aeejj99@194.109.6.166> <ywbVJtWmfEZYFw3K@invalid.uk.co.demon.merlyn.invalid>
Date 2016-12-29 18:36 +0100
Message-ID <XnsA6EDBD4CF42A5eejj99@194.109.6.166> (permalink)

Show all headers | View raw


Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> wrote on 29 Dec 2016 
in comp.lang.javascript:

> In comp.lang.javascript message <XnsA6EBDD7D05C4Aeejj99@194.109.6.166>,
> Tue, 27 Dec 2016 21:46:23, Evertjan. <exxjxw.hannivoort@inter.nl.net>
> posted:
> 
>>
>>age = presentYear - birthYear;
>>if (setFullYear(birthYear,birthMonth-1,birthDate) <
>>  setFullYear(birthYear,presentMonth-1,presentDate))
>>     age--;
>>
> 
> I rather suspect that the boolean expression will fail if the two dates
> are the same but in one case the beginning of the date is in Winter Time
> and the other case is in Summer Time or /vice versa/.  To see this, it
> will probably be necessary to be using UK time or Azores Time.

I don't thinks so, as this is about dates without time,
so whether there is a 1 hour difference would make a difference with a 
boolean equal [==], NOT with a boolen less than [<], as the difference being
23, 24 or 25 hours surly won't matter.

> There is, of course, the question of someone born in a distant Time
> Zone.

No, because common age in years in this sense does not imply that your 
become some age at 15 hours of your birthday, you become that age at zero 
hours local time wherever you are in the world.

If not you would probably also have to account for a 0.24.. leapday 
correction becoming setting that hour nearly 3 hours earlier for 3 years and 
then nearly 9 hours later in the 4th year, the 'nearly' accounting for the 
100 year mean. 

Sillyness of sillynesses?

> Use setUTCFullYear instead, to remove Summer Time concern; and, AISB,
> much simpler to use simple arithmetic to compare, for example by using
> the ISO8601 YYYYMMDD date strings.
> 
> For greater ages, such as those of buildings, there is another problem,
> as is illustrated by the following :- AIUI, Miguel Cervantes was buried
> on 1616 04 23 (the day after his death) - and William Shakespeare died
> on 1616 04 23, ten days later.

So then you simply would have to include what time definitions you use, if 
they are different, leading to the same sillyness of sillynesses, as we are 
not striving for such extreme exactness.

Only in law [age of majority, age of sexual consent, marriageable age, 
school leaving age, drinking age, driving age, voting age, smoking age]
the exact date would have consquences for Miguel and William.


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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