M $ comic "backward compatibility"

xiaoxiao2021-03-06  62

BUG Description: The year on the SFO calendar is shown under Mozilla for 104 years instead of 2004.

Bug Reason: The year is generated by the Calendar.js script.

Var cl_thisyear = cl_today.getYear ();

Use a getYear () method with Y2K issues. According to the ECMAScript ED3 standard, the return is YearFromTime (LocalTime (T)) - 1900. The reason whose MS IE is normal because JScript is not standard.

Solution: Use the getFullyear () method.

Attached, JScript documentation about getYear () instructions:

This method has been out of time, which provides this method to keep backward compatibility. Please use the getFullyear method.

For the 1900-1999, the return year value is a two-digit integer, which represents the gap between the previous year and 1900. For other years, the return value is a four-digit integer. For example, the return value of 1996 is 96, and the return value of 1825 and 2025 is corresponding to 1825 and 2025.

Note For JScript version 1.0, getYear returned to the gap between the year and 1900 in the Date object. For example, the return value of 1899 is -1, and the return value of 2000 is 100.

Pay attention to the ridicity of MS, since "keep back compatibility", you should not change the semantics in any case because it does not predict how early code uses the getYear method (and it possible to handle Y2K issues) Workaround). And it seems to be a convenient to return to 4 years from the year of 1900-1999, it is actually caused:

The originally possible patch code for getYear's Y2K problem (such as the return value 1900) does not work, the opposite is the non-expected value. Mask the getYear's Y2K problem so that the programmer continues to use the getYear that should not be used instead of replacing it on the getFullyear method.

Microsoft does not follow the standard and the unused "backward compatibility" - although it has enough resources: money and strong people, but still do not avoid many obvious Inconformable and Incompatible, just use the sloppy or mistakes, it is not convincing ... Therefore, this actually illustrates its monopoly through its monopoly status. Despite this, developing documents should be done, development tools should be done - let you more convenient (more convenient to do M $'s slaves?), But in their bones, it is actually neglecting developers (not willing to be a slave. ?)beneficial.

转载请注明原文地址:https://www.9cbs.com/read-111513.html

New Post(0)