Christian Seiler: getYear() in Mozilla, IE und Opera

Beitrag lesen

Hallo Mathias,

Zu den Hintergründen siehe </archiv/2004/4/77852/#m450091>. »Falsch« ist hier eher die jede Logik entbehrende Entwicklung der JavaScript-Spezifikationen von Netscape.

Die Idee ist aber nicht von Netscape. Ich darf aus der UNIX-Manpage für localtime zitieren:

[...]
       asctime,   ctime,   gmtime,   localtime,  mktime,  asctime_r,  ctime_r,
       gmtime_r, localtime_r - transform date and time to broken-down time  or
       ASCII
[...]
       Broken-down time is stored in the structure  tm  which  is  defined  in
       <time.h> as follows:

struct tm {
                      int     tm_sec;         /* seconds */
                      int     tm_min;         /* minutes */
                      int     tm_hour;        /* hours */
                      int     tm_mday;        /* day of the month */
                      int     tm_mon;         /* month */
                      int     tm_year;        /* year */
                      int     tm_wday;        /* day of the week */
                      int     tm_yday;        /* day in the year */
                      int     tm_isdst;       /* daylight saving time */
              };

The members of the tm structure are:
[...]
       tm_year
              The number of years since 1900.

Und tm_year enthält unter UNIX dieses Jahr tatsächlich 104. Die Netscape-Leute haben schlichtweg die Funktion getYear() auf dieses Mitglied der struct tm gemappt.

Und ja, es entbehrt jeglicher Logik, hat jedoch Tradition[tm].

Viele Grüße,
Christian