Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: src/macros.py

Issue 9572008: Implement date library functions in C++. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add DST test and fix bugs. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2006-2009 the V8 project authors. All rights reserved. 1 # Copyright 2006-2009 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 # REGEXP_NUMBER_OF_CAPTURES 157 # REGEXP_NUMBER_OF_CAPTURES
158 macro NUMBER_OF_CAPTURES(array) = ((array)[0]); 158 macro NUMBER_OF_CAPTURES(array) = ((array)[0]);
159 159
160 # Limit according to ECMA 262 15.9.1.1 160 # Limit according to ECMA 262 15.9.1.1
161 const MAX_TIME_MS = 8640000000000000; 161 const MAX_TIME_MS = 8640000000000000;
162 # Limit which is MAX_TIME_MS + msPerMonth. 162 # Limit which is MAX_TIME_MS + msPerMonth.
163 const MAX_TIME_BEFORE_UTC = 8640002592000000; 163 const MAX_TIME_BEFORE_UTC = 8640002592000000;
164 164
165 # Gets the value of a Date object. If arg is not a Date object 165 # Gets the value of a Date object. If arg is not a Date object
166 # a type error is thrown. 166 # a type error is thrown.
167 macro DATE_VALUE(arg) = (%_ClassOf(arg) === 'Date' ? %_ValueOf(arg) : ThrowDateT ypeError()); 167 macro CHECK_DATE(arg) = if (%_ClassOf(arg) !== 'Date') ThrowDateTypeError();
168 macro DAY(time) = ($floor(time / 86400000)); 168 macro LOCAL_DATE_VALUE(arg) = (%_DateField(arg, 0) + %_DateField(arg, 21));
169 macro NAN_OR_DATE_FROM_TIME(time) = (NUMBER_IS_NAN(time) ? time : DateFromTime(t ime)); 169 macro UTC_DATE_VALUE(arg) = (%_DateField(arg, 0));
170 macro HOUR_FROM_TIME(time) = (Modulo($floor(time / 3600000), 24)); 170
171 macro MIN_FROM_TIME(time) = (Modulo($floor(time / 60000), 60)); 171 macro LOCAL_YEAR(arg) = (%_DateField(arg, 1));
172 macro NAN_OR_MIN_FROM_TIME(time) = (NUMBER_IS_NAN(time) ? time : MIN_FROM_TIME(t ime)); 172 macro LOCAL_MONTH(arg) = (%_DateField(arg, 2));
173 macro SEC_FROM_TIME(time) = (Modulo($floor(time / 1000), 60)); 173 macro LOCAL_DAY(arg) = (%_DateField(arg, 3));
174 macro NAN_OR_SEC_FROM_TIME(time) = (NUMBER_IS_NAN(time) ? time : SEC_FROM_TIME(t ime)); 174 macro LOCAL_WEEKDAY(arg) = (%_DateField(arg, 4));
175 macro MS_FROM_TIME(time) = (Modulo(time, 1000)); 175 macro LOCAL_HOUR(arg) = (%_DateField(arg, 5));
176 macro NAN_OR_MS_FROM_TIME(time) = (NUMBER_IS_NAN(time) ? time : MS_FROM_TIME(tim e)); 176 macro LOCAL_MIN(arg) = (%_DateField(arg, 6));
177 macro LOCAL_SEC(arg) = (%_DateField(arg, 7));
178 macro LOCAL_MS(arg) = (%_DateField(arg, 8));
179 macro LOCAL_DAYS(arg) = (%_DateField(arg, 9));
180 macro LOCAL_TIME_IN_DAY(arg) = (%_DateField(arg, 10));
181
182 macro UTC_YEAR(arg) = (%_DateField(arg, 11));
183 macro UTC_MONTH(arg) = (%_DateField(arg, 12));
184 macro UTC_DAY(arg) = (%_DateField(arg, 13));
185 macro UTC_WEEKDAY(arg) = (%_DateField(arg, 14));
186 macro UTC_HOUR(arg) = (%_DateField(arg, 15));
187 macro UTC_MIN(arg) = (%_DateField(arg, 16));
188 macro UTC_SEC(arg) = (%_DateField(arg, 17));
189 macro UTC_MS(arg) = (%_DateField(arg, 18));
190 macro UTC_DAYS(arg) = (%_DateField(arg, 19));
191 macro UTC_TIME_IN_DAY(arg) = (%_DateField(arg, 20));
192
193 macro TIMEZONE_OFFSET(arg) = (%_DateField(arg, 21));
194
195 macro SET_UTC_DATE_VALUE(arg, value) = (%DateSetValue(arg, value, 1));
196 macro SET_LOCAL_DATE_VALUE(arg, value) = (%DateSetValue(arg, value, 0));
177 197
178 # Last input and last subject of regexp matches. 198 # Last input and last subject of regexp matches.
179 macro LAST_SUBJECT(array) = ((array)[1]); 199 macro LAST_SUBJECT(array) = ((array)[1]);
180 macro LAST_INPUT(array) = ((array)[2]); 200 macro LAST_INPUT(array) = ((array)[2]);
181 201
182 # REGEXP_FIRST_CAPTURE 202 # REGEXP_FIRST_CAPTURE
183 macro CAPTURE(index) = (3 + (index)); 203 macro CAPTURE(index) = (3 + (index));
184 const CAPTURE0 = 3; 204 const CAPTURE0 = 3;
185 const CAPTURE1 = 4; 205 const CAPTURE1 = 4;
186 206
(...skipping 13 matching lines...) Expand all
200 const TYPE_EXTENSION = 1; 220 const TYPE_EXTENSION = 1;
201 const TYPE_NORMAL = 2; 221 const TYPE_NORMAL = 2;
202 222
203 # Matches Script::CompilationType from objects.h 223 # Matches Script::CompilationType from objects.h
204 const COMPILATION_TYPE_HOST = 0; 224 const COMPILATION_TYPE_HOST = 0;
205 const COMPILATION_TYPE_EVAL = 1; 225 const COMPILATION_TYPE_EVAL = 1;
206 const COMPILATION_TYPE_JSON = 2; 226 const COMPILATION_TYPE_JSON = 2;
207 227
208 # Matches Messages::kNoLineNumberInfo from v8.h 228 # Matches Messages::kNoLineNumberInfo from v8.h
209 const kNoLineNumberInfo = 0; 229 const kNoLineNumberInfo = 0;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698