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

Side by Side Diff: runtime/lib/date_patch.dart

Issue 11748016: Make ~/, round, ceil, floor, truncate return ints. Remove toInt. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Checked mode fixes. Created 7 years, 11 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // Dart core library. 4 // Dart core library.
5 5
6 // VM implementation of _DateImpl. 6 // VM implementation of _DateImpl.
7 patch class _DateImpl { 7 patch class _DateImpl {
8 /* patch */ _DateImpl(int year, 8 /* patch */ _DateImpl(int year,
9 int month, 9 int month,
10 int day, 10 int day,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 ((y.remainder(100) != 0) || (y.remainder(400) == 0)); 176 ((y.remainder(100) != 0) || (y.remainder(400) == 0));
177 } 177 }
178 178
179 static _brokenDownDateToMillisecondsSinceEpoch( 179 static _brokenDownDateToMillisecondsSinceEpoch(
180 int year, int month, int day, 180 int year, int month, int day,
181 int hour, int minute, int second, int millisecond, 181 int hour, int minute, int second, int millisecond,
182 bool isUtc) { 182 bool isUtc) {
183 // Simplify calculations by working with zero-based month. 183 // Simplify calculations by working with zero-based month.
184 --month; 184 --month;
185 // Deal with under and overflow. 185 // Deal with under and overflow.
186 year += (month / 12).floor().toInt(); 186 year += (month / 12).floor();
187 month = month % 12; 187 month = month % 12;
188 188
189 // First compute the seconds in UTC, independent of the [isUtc] flag. If 189 // First compute the seconds in UTC, independent of the [isUtc] flag. If
190 // necessary we will add the time-zone offset later on. 190 // necessary we will add the time-zone offset later on.
191 int days = day - 1; 191 int days = day - 1;
192 days += _DAYS_UNTIL_MONTH[_isLeapYear(year) ? 1 : 0][month]; 192 days += _DAYS_UNTIL_MONTH[_isLeapYear(year) ? 1 : 0][month];
193 days += _dayFromYear(year); 193 days += _dayFromYear(year);
194 int millisecondsSinceEpoch = days * Duration.MILLISECONDS_PER_DAY + 194 int millisecondsSinceEpoch = days * Duration.MILLISECONDS_PER_DAY +
195 hour * Duration.MILLISECONDS_PER_HOUR + 195 hour * Duration.MILLISECONDS_PER_HOUR +
196 minute * Duration.MILLISECONDS_PER_MINUTE+ 196 minute * Duration.MILLISECONDS_PER_MINUTE+
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 static String _timeZoneNameForClampedSeconds(int secondsSinceEpoch) 316 static String _timeZoneNameForClampedSeconds(int secondsSinceEpoch)
317 native "DateNatives_timeZoneName"; 317 native "DateNatives_timeZoneName";
318 318
319 static int _timeZoneOffsetInSecondsForClampedSeconds(int secondsSinceEpoch) 319 static int _timeZoneOffsetInSecondsForClampedSeconds(int secondsSinceEpoch)
320 native "DateNatives_timeZoneOffsetInSeconds"; 320 native "DateNatives_timeZoneOffsetInSeconds";
321 321
322 static int _localTimeZoneAdjustmentInSeconds() 322 static int _localTimeZoneAdjustmentInSeconds()
323 native "DateNatives_localTimeZoneAdjustmentInSeconds"; 323 native "DateNatives_localTimeZoneAdjustmentInSeconds";
324 } 324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698