OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 | 950 |
951 | 951 |
952 // ECMA 262 - B.2.5 | 952 // ECMA 262 - B.2.5 |
953 function DateSetYear(year) { | 953 function DateSetYear(year) { |
954 var t = LocalTime(GetTimeFrom(this)); | 954 var t = LocalTime(GetTimeFrom(this)); |
955 if ($isNaN(t)) t = 0; | 955 if ($isNaN(t)) t = 0; |
956 year = ToNumber(year); | 956 year = ToNumber(year); |
957 if ($isNaN(year)) return %_SetValueOf(this, $NaN); | 957 if ($isNaN(year)) return %_SetValueOf(this, $NaN); |
958 year = (0 <= TO_INTEGER(year) && TO_INTEGER(year) <= 99) | 958 year = (0 <= TO_INTEGER(year) && TO_INTEGER(year) <= 99) |
959 ? 1900 + TO_INTEGER(year) : year; | 959 ? 1900 + TO_INTEGER(year) : year; |
960 var day = MakeDay(year, GetMonthFrom(this), GetDateFrom(this)); | 960 var day = MakeDay(year, MonthFromTime(t), DateFromTime(t)); |
961 return %_SetValueOf(this, TimeClip(UTC(MakeDate(day, TimeWithinDay(t))))); | 961 return %_SetValueOf(this, TimeClip(UTC(MakeDate(day, TimeWithinDay(t))))); |
962 } | 962 } |
963 | 963 |
964 | 964 |
965 // ECMA 262 - B.2.6 | 965 // ECMA 262 - B.2.6 |
966 // | 966 // |
967 // Notice that this does not follow ECMA 262 completely. ECMA 262 | 967 // Notice that this does not follow ECMA 262 completely. ECMA 262 |
968 // says that toGMTString should be the same Function object as | 968 // says that toGMTString should be the same Function object as |
969 // toUTCString. JSC does not do this, so for compatibility we do not | 969 // toUTCString. JSC does not do this, so for compatibility we do not |
970 // do that either. Instead, we create a new function whose name | 970 // do that either. Instead, we create a new function whose name |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 "setFullYear", DateSetFullYear, | 1031 "setFullYear", DateSetFullYear, |
1032 "setUTCFullYear", DateSetUTCFullYear, | 1032 "setUTCFullYear", DateSetUTCFullYear, |
1033 "toGMTString", DateToGMTString, | 1033 "toGMTString", DateToGMTString, |
1034 "toUTCString", DateToUTCString, | 1034 "toUTCString", DateToUTCString, |
1035 "getYear", DateGetYear, | 1035 "getYear", DateGetYear, |
1036 "setYear", DateSetYear | 1036 "setYear", DateSetYear |
1037 )); | 1037 )); |
1038 } | 1038 } |
1039 | 1039 |
1040 SetupDate(); | 1040 SetupDate(); |
OLD | NEW |