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

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

Issue 10790099: Fix printing of dates with year 0. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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
« no previous file with comments | « lib/compiler/implementation/lib/mockimpl.dart ('k') | tests/corelib/date_time8_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 DateImplementation. 6 // VM implementation of DateImplementation.
7 class DateImplementation implements Date { 7 class DateImplementation implements Date {
8 static final int _MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000; 8 static final int _MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000;
9 9
10 DateImplementation(int years, 10 DateImplementation(int years,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 Date.MON; 189 Date.MON;
190 } 190 }
191 191
192 String toString() { 192 String toString() {
193 String fourDigits(int n) { 193 String fourDigits(int n) {
194 int absN = n.abs(); 194 int absN = n.abs();
195 String sign = n < 0 ? "-" : ""; 195 String sign = n < 0 ? "-" : "";
196 if (absN >= 1000) return "$n"; 196 if (absN >= 1000) return "$n";
197 if (absN >= 100) return "${sign}0$absN"; 197 if (absN >= 100) return "${sign}0$absN";
198 if (absN >= 10) return "${sign}00$absN"; 198 if (absN >= 10) return "${sign}00$absN";
199 if (absN >= 1) return "${sign}000$absN"; 199 return "${sign}000$absN";
200 } 200 }
201 String threeDigits(int n) { 201 String threeDigits(int n) {
202 if (n >= 100) return "${n}"; 202 if (n >= 100) return "${n}";
203 if (n >= 10) return "0${n}"; 203 if (n >= 10) return "0${n}";
204 return "00${n}"; 204 return "00${n}";
205 } 205 }
206 String twoDigits(int n) { 206 String twoDigits(int n) {
207 if (n >= 10) return "${n}"; 207 if (n >= 10) return "${n}";
208 return "0${n}"; 208 return "0${n}";
209 } 209 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 483
484 static String _timeZoneNameForClampedSeconds(int secondsSinceEpoch) 484 static String _timeZoneNameForClampedSeconds(int secondsSinceEpoch)
485 native "DateNatives_timeZoneName"; 485 native "DateNatives_timeZoneName";
486 486
487 static int _timeZoneOffsetInSecondsForClampedSeconds(int secondsSinceEpoch) 487 static int _timeZoneOffsetInSecondsForClampedSeconds(int secondsSinceEpoch)
488 native "DateNatives_timeZoneOffsetInSeconds"; 488 native "DateNatives_timeZoneOffsetInSeconds";
489 489
490 static int _localTimeZoneAdjustmentInSeconds() 490 static int _localTimeZoneAdjustmentInSeconds()
491 native "DateNatives_localTimeZoneAdjustmentInSeconds"; 491 native "DateNatives_localTimeZoneAdjustmentInSeconds";
492 } 492 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/mockimpl.dart ('k') | tests/corelib/date_time8_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698