"The first month of the year is JANUARY which is 0"
Yes but not what any other month is. Additionaly no mention is made as
to the ordering. You are left to assume the sequence. Is FEBRUARY 1, -1
or is it 4? Is MARCH 2, -1 or is it 8?
Principle of least confusion. All other things being equal, assume
things are the most obvious. I hope I don't ever have to use any of
your libraries if you think it's ok to define the constants in a
different order just because the spec doesn't say you can't!
> "The Java Programming Language" and "The Java Language Specification"
are also very clear that months are integers in the range 0..11.
Integers or ints?
What do you think?
> The reason is pretty simple. Go into Finder and look for "time.h";
> open it or load it in Xtools or whatever; you'll find this C
> structure; look at the comment for tm_mon. Java libraries number
months from 0..11 because that's what C & C++ do, and Java is a direct
descendent of C/C++.
This might be the reason but it is not a requirement. C++ is a direct
descendent of C. Java shares a syntactic similarities but has
significant semantic differences, you might as well say Java is a
direct descendent of Smalltalk or Objective C.
We're not talking about the language here but the APIs. It's
blatantly obvious to anyone who was familiar with the relevant things
at the time that the Java API is very heavily determined by the
capabilities of POSIX and the C standard library. Heck, I'm
constantly surprised that File.delete() isn't called unlink()!
Sorry, I haven't found time.h yet, All my time.h's are different then
this. Its just hiding and I don't have the time to find it but its
really not that important.
struct tm {
int tm_sec; /* seconds after the minute [0-60] */
Gee, 61 seconds in a minute. I'm sure there is a reason for this, I
just can't think of it right now. Is this the same in Java?
Actually, yes, that is correct. Seconds can go from 0 to 60 if there
is a leap second in that year.
> int tm_min; /* minutes after the hour [0-59] */
int tm_hour; /* hours since midnight [0-23] */
int tm_mday; /* day of the month [1-31] */
Seems out of place. Why doesn't it start with 0? Not very C like. :-P
Surely that's obvious? The definition of the structure is for
convenience. Hours, minutes and day of month are normally used as
they are, as a NUMBER. Month and day are almost always used as an
INDEX into an array of month or day names. The confusion with month
arises because you might use it either way, as an index or a number,
depending on whether you want to write 2004-12-31 or 31 Dec 2004.
They had to pick one, they chose index. But that decision was made a
long, long time before Java was even a merest twinkle in James
Gosling's eye.
> int tm_mon; /* months since January [0-11] */
At least it is explained properly. Note, it is not the month of the
year. It is the number of months past January. Seems something was lost
in translation.
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday [0-6] */
int tm_yday; /* days since January 1 [0-365] */
int tm_isdst; /* Daylight Savings Time flag */
long tm_gmtoff; /* offset from CUT in seconds */
char *tm_zone; /* timezone abbreviation */
> };
I have no problem with the fact that java.util.Calendar.JANUARY is 0.
My problem is with poor documentation and the miss use of the provided
constants.
-Rolf
--
Rolf Howarth, Square Box Systems Ltd, Stratford-upon-Avon UK.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden