Leap Year

#1
2012 is a leap year. Take note of the following;

Code:
echo %@date[02/29/2012]
11747

echo %@date[02/30/2012]
11748

echo %@date[02/31/2012]
11749

echo %@date[03/01/2012]
11748
February 30, 2012 returns the same number of days since January 1, 1980 as March 1, 2012.

Why are 02/30/2012 and 02/31/2012 being recognized as valid dates?

I'm using TCC 11.

Joe
 
#2
| February 30, 2012 returns the same number of days since January 1,
| 1980 as March 1, 2012.
|
| Why are 02/30/2012 and 02/31/2012 being recognized as valid dates?

The @date function, at least as far back as V6, accepted the 31st day of
every month. The documentation never stated that it validates its input! Its
working principle is GIGO...
--
Steve
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,556
46
Albuquerque, NM
prospero.unm.edu
#3
| February 30, 2012 returns the same number of days since January 1,
| 1980 as March 1, 2012.
|
| Why are 02/30/2012 and 02/31/2012 being recognized as valid dates?

The @date function, at least as far back as V6, accepted the 31st day of
every month. The documentation never stated that it validates its input! Its
working principle is GIGO...
Possibly of interest: http://www.unm.edu/~cdye/plugins/iso8601.html
 
May 29, 2008
529
3
Groton, CT
#6
I love these new functions, Charles. Obviously, this supersedes your earlier pickdate plugin.

From the iso8601.html page:

"Formats 0 through 3 return two-digit years, for compatibility with Take Command's native behavior. Where compatibility is not an issue, I recommend using formats 256-259 instead. These formats are equivalent to 0-3, but return four-digit years. (A note in TakeCmd.h suggests that TCC supports similar formats internally; unfortunately, this capability doesn't seem to be available to the user.)"

In fact, in an earlier version of TC, I had noticed those formats 256-259 worked, and inquired whether I could depend on them. Rex said no, that they weren't valid formats, and they were removed from the next release.

Thanks, Charles, for making those available again.
 
#7
Steve,


>> Why are 02/30/2012 and 02/31/2012 being recognized as valid dates?
>
> The @date function, at least as far back as V6, accepted the 31st day
> of every month. The documentation never stated that it validates its
> input! Its working principle is GIGO...
On the othe hand, there must be some internal test to decide that

echo%@makedate[11748]
01.03.12

and not 30.02.12.

At least you can use this to validate a given input date.

Best Regards,

* Klaus Meinhard *
<www.4dos.info>