function TCalendar.IsLeapYear(AYear: Integer): Boolean;
begin
Result := (AYear mod 4 = 0) and ((AYear mod 100 <> 0) or (AYear mod 400 =
0));
end;
It implies (if I understand this properly) that in order to tell that a year
is a leap year, the number has to be divisible by 4 and has to be either NOT
divisible by 100 but divisible by 400.
We all know that the year 2000 is a leap year, right? Write down all leap
years through year 2100. Is 2100 not a leap year too? Don't think it meets
function's criteria. As a matter of fact, try to set Feb/2100 in
calendar.pas and see what happens. Same problem with every other date
component I've seen.
Am I missing something here? Is 25 x 4 not 100 any more?
Thanks.
rb <r...@quantum.ca> skrev i en
nyhedsmeddelelse:7l5lqa$kg...@forums.borland.com...
>
> I'm sort of unclear how to calculate which year is a leap year. This is a
> function from calendar.pas (samples).
>Is 2100 not a leap year too?
2100 is not a leap year.
--
Ray Lischner (http://www.tempest-sw.com/)
Author of "Hidden Paths of Delphi 3: Experts, Wizards, and the Open Tools API"
>It implies (if I understand this properly) that in order to tell that a year
>is a leap year, the number has to be divisible by 4 and has to be either NOT
>divisible by 100 but divisible by 400.
Yes, a leap year is a year that is an even multiple of 4, unless it's
an even multiple of 100. In that case, it has to be an even multiple
of 400 to be considered a leap year.
For example:
1800: No
1900: No
2000: Yes
2100: No
2200: No
2300: No
2400: Yes
[more snip]
>function's criteria. As a matter of fact, try to set Feb/2100 in
>calendar.pas and see what happens. Same problem with every other date
>component I've seen.
Those data components are acting correctly. 29 Feb 2100 does not
exist, so it is not really a "problem". It's the same as asking for
December 45th in any year. :)
Best regards,
Pete C.
=================================================================
I'm really cervasio at airmail dot net, if you want to email me.
Fight spam...Join CAUCE! Learn more at http://www.cauce.org
All UCE goes to my ISP's abuse dept. They get people terminated!
=================================================================
Thanks for your responses, though I'd use some brute force to verify this
calculation:
2000, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72,
76, 80, 84, 88, 92, 2096 AND 2100.
How do you explain this?
Explain what? 2100 is divisible by 4 and by 100, but NOT divisible by 400,
so it's NOT a leap year. That's the rule. The calculation you saw is
correct. To break it into discrete parts it could be this:
if year mod 400 = 0 then leap := True
else if year mod 100 = 0 then leap := False
else if year mod 4 = 0 then leap := True
else leap := False;
But the code you posted is MUCH more efficient. BTW the code you posted is
identical to that in Delphi's IsLeapYear function found in SysUtils.
--
Wayne Niddery - WinWright Consulting
RADBooks - http://home.ican.net/~wniddery/RADBooks.html
Bill of NO Rights; ARTICLE II: You do NOT have the right to never be
offended. This country is based on freedom, and that means freedom for
everyone not just you! You may leave the room, change the TV channel,
express a different opinion, etc., but you may still be offended. That's
YOUR problem.
> >
> >2000, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68,
72,
> >76, 80, 84, 88, 92, 2096 AND 2100.
> >
> >How do you explain this?
>
> Explain what? 2100 is divisible by 4 and by 100, but NOT divisible by 400,
> so it's NOT a leap year. That's the rule. The calculation you saw is
Here you go again. You're taking their function for granted. All I'm asking
you to do is to think about the array I wrote previously. Or better yet,
tell me if the year 2096 is a leap year. If it is, how can it be that 4
years later, the year 2100 doesn't get to be a leap one. That would also
mean that the year 2004 IS a leap year. That makes 8 years leap. I'm very
sorry but I'm having a hard time understanding this.
rb
You are making a mountain out of a mole hill here. This is the scientifically
accepted way of figuring out leap years. All a leap year is is an error
correction to keep the same day of the year to represent the same relative
position in space to the Sun.
What part of "Leap years are necessary because the actual length of a year is
365.242 days, not 365 days, as commonly stated. Therefore, on years that are
evenly divisible by 4 (like 1992, for example) an extra day is added to the
calendar on February 29th. However, since the year is slightly less than 365.25
days long, adding an extra day every 4 years results in about 3 extra days being
added over a period of 400 years. For this reason, only 1 out of every 4 century
years is considered as a leap year." didn't you understand? This is all based
on science. If you don't want to trust the science behind this then I think
there is a meeting of the Flat Earth Society starting in a few hours <vbg>.
rb wrote:
>
> You're taking their function for granted. All I'm asking you to do is to
> think about the array I wrote previously. Or better yet, tell me if the year
> 2096 is a leap year. If it is, how can it be that 4 years later, the year
> 2100 doesn't get to be a leap one. That would also mean that the year 2004
> IS a leap year. That makes 8 years leap. I'm very sorry but I'm having a
> hard time understanding this.
>
> rb
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Maybe it was infatuation or the thrill of the chase.
Maybe you were always beyond my reach and my heart was playing safe.
But was that love in your eye I saw or the reflection of mine?
Give me time, won't you give me that time!
Welcome back to the circus. (Fish)
--
--Rob
rb <r...@quantum.ca> wrote in message news:7l6p6f$lk...@forums.borland.com...
2096 is a leap year. 2100 is not a leap year. 2104 is a leap year. Yes,
there will be an 8 year gap. The function in Delphi is correct.
Do you understand what leap years are for? There are 365 days, 6 hr, 9 min,
9.5 sec in a year. Because of the fractional part, leap years were added.
Otherwise the seasons would drift away from the calendar. Because 6 hr, 9
min, 9.5 sec is close to 6 hours, or 1/4 of a day, adding an extra day every
four years almost compensates. However, that compensates a little too much,
so it was decided to *not* have a leap year every 100 years. But that did
not quite compensate enough, so consequently the leap year was added back
for years divisible by 400.
-Mike
>Thanks for your responses, though I'd use some brute force to verify this
>calculation:
>
>2000, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72,
>76, 80, 84, 88, 92, 2096 AND 2100.
>
>How do you explain this?
You can write down any numbers you want, but that doesn't change the
fact that 2100 is not a leap year. If you don't believe us, try the
National Institute for Standards and Technology:
http://www.bldrdoc.gov/timefreq/faq/faq.htm#18
--
So, lets look at the function to see if it follows the rules:
(AYear mod 4 = 0) // every year evenly divisible by 4
and ((AYear mod 100 <> 0) // year must not be evenly divisible by 100
or (AYear mod 400 = 0)); // unless it is evenly divisible by 400
Your analysis of the function (2nd paragraph below) is 99% correct.
Change it to:
It implies (if I understand this properly) that in order to tell that a
year
is a leap year, the number has to be EVENLY divisible by 4 and has to be
NOT
EVENLY divisible by 100 UNLESS EVENLY divisible by 400.
Now, let's look at some sample dates:
By the definition, we know that a 1996 is a leap year. (Evenly divisible
by 4 and not a century year.)
1997 - 1999 are not leap years (not evenly divisible by 4).
2000 is a leap year - evenly divisible by 4, and since it's a century
year, it must also be evenly divisible by 400.
Now, jump forward a century.
By the definition, 2096 is a leap year.
2097-2099 are not leap years.
2100 is evenly divisible by 4, and it's a century year that is not
evenly divisible by 400. So, it is not a leap year.
When running the above dates through the formula, we get corresponding
answers. So, we have validated the formula as being correct. Since it
has now been validated, we can "take this function for granted".
The key thing to remember is that not every 4th year is a leap year -
there are exceptions.
In a 400 year timeframe, there are a potential 100 leap years. Yet, we
only have 97 leap years during this timeframe. The three century years
that are not divisible by 400 are not leap years, and these are the
"missing" years.
I hope that this clarified it for you. If not, then I'm afraid that
you'll just have to push the "I Believe" button on this issue.
Wayne
(You know, the term "leap year" is probably a bad one - it doesn't
describe what's really going on. In those years, we add an extra day to
the calander (Feb. 29th))
>function TCalendar.IsLeapYear(AYear: Integer): Boolean;
>begin
> Result := (AYear mod 4 = 0) and ((AYear mod 100 <> 0) or (AYear mod 400 =
>0));
>end;
>It implies (if I understand this properly) that in order to tell that a year
>is a leap year, the number has to be divisible by 4 and has to be either NOT
>divisible by 100 but divisible by 400.
rb wrote:
>
> You're right, IsLeapYear was taken from control.pas as I said in my first
> message.
>
> > >
> > >2000, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68,
> 72,
> > >76, 80, 84, 88, 92, 2096 AND 2100.
> > >
> > >How do you explain this?
> >
> > Explain what? 2100 is divisible by 4 and by 100, but NOT divisible by 400,
> > so it's NOT a leap year. That's the rule. The calculation you saw is
>
> Here you go again. You're taking their function for granted. All I'm asking
> you to do is to think about the array I wrote previously. Or better yet,
> tell me if the year 2096 is a leap year. If it is, how can it be that 4
> years later, the year 2100 doesn't get to be a leap one. That would also
> mean that the year 2004 IS a leap year. That makes 8 years leap. I'm very
> sorry but I'm having a hard time understanding this.
>
> rb
>> National Institute for Standards and Technology:
>> http://www.bldrdoc.gov/timefreq/faq/faq.htm#18
>You're taking their function for granted.
Whose function / definition do you want? There are some things that you
learnt in infant / primary school which you find are not strictly
correct. You are not taught the finer details at that time since it
would be too complex. Sometimes the teacher is just plain wrong as
well.
This is why leap years have become part of the Year2000 date handling
problem.
Regards,
Chris Roberts
>> Explain what? 2100 is divisible by 4 and by 100, but NOT divisible by 400,
>> so it's NOT a leap year.
>unless it's divisible by 4000 (the latest correction added to the
>defintion).
Start fixing those Y4K bugs now!
--
Ray Lischner, co-author of Shakespeare for Dummies
http://www.bardware.com
Timo
rb <r...@quantum.ca> schreef in berichtnieuws
7l6p6f$lk...@forums.borland.com...
>
> Ray Lischner <delphi.at.te...@nospam.com> wrote in message
> news:3777ba32...@forums.inprise.com...
> > On Sun, 27 Jun 1999 16:47:39 -0400, "rb" <r...@quantum.ca> wrote:
> >
> > >Thanks for your responses, though I'd use some brute force to verify
this
> > >calculation:
> > >
> > >2000, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68,
> 72,
> > >76, 80, 84, 88, 92, 2096 AND 2100.
> > >
> > >How do you explain this?
> >
> > You can write down any numbers you want, but that doesn't change the
> > fact that 2100 is not a leap year. If you don't believe us, try the
> > National Institute for Standards and Technology:
> > http://www.bldrdoc.gov/timefreq/faq/faq.htm#18
> >
> That's great. I've replied to the other guy with the same theory:
>
Leap Year is a Man Made correction factor because the universe is not tuned
to our calendar. Even with every fourth year being a correction for the 1/4
day lose suffered each preceding year, our calendar still gets out of kilter
every 4 centuries or so. We kind of overshoot fixing it and have to
re-adjust.
If you don't like it, make a better mouse-trap, 'er I mean wristwatch. Or
don't write applications that'll be around in year 2400.
--
Larry Killen, M.S.
Software Engineer
TRW Systems Integration Group
rb <r...@quantum.ca> wrote in message news:7l6p4a$lk...@forums.borland.com...
> You're right, IsLeapYear was taken from control.pas as I said in my first
> message.
>
> > >
> > >2000, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68,
> 72,
> > >76, 80, 84, 88, 92, 2096 AND 2100.
> > >
> > >How do you explain this?
> >
> > Explain what? 2100 is divisible by 4 and by 100, but NOT divisible by
400,
> > so it's NOT a leap year. That's the rule. The calculation you saw is
>
> Here you go again. You're taking their function for granted. All I'm
I seem to recall that the solid rocket boosters for the space shuttle were
test fired while mounted horizontally on the ground. All we need is enough
of them ... <g>
-Mike
The 'wrong' ones were sanctioned by a Pope Gregory back in 1582 so for this
problem I suppose you would be justified if you just blamed God!
David Thomas
da...@diespam.supporthq.com
>Here you go again. You're taking their function for granted. All I'm asking
>you to do is to think about the array I wrote previously. Or better yet,
>tell me if the year 2096 is a leap year. If it is, how can it be that 4
>years later, the year 2100 doesn't get to be a leap one. That would also
>mean that the year 2004 IS a leap year. That makes 8 years leap. I'm very
>sorry but I'm having a hard time understanding this.
This has already occurred, by the way: 1900 also was NOT a leap year, even
though 1896 and 1904 were. Of course, there weren't nearly as many people
reading newsgroups at that time.
RB, you seem to have convinced yourself that February 29 always comes
exactly once in every 4 years, no more, no less. That isn't so. Once you
divest yourself of that incorrect notion, you should be fine.
- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc
You're one hell of funny guy. I would suggest though you should choose your
words more carefully. Making fun of people's questions hasn't been the way
people in IT communicate among themselves.
rb
Yes brainstormer, you're absolutely right. However, if you were alive 400+
years ago you would be giving me this attitude on how Earth is flat and is a
center of the universe.
But I guess, you've always been a good boy a did what other tell you - no
questions asked, ha?
rb
Thanks.
rb