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

Side by Side Diff: frog/leg/lib/date_helper.dart

Issue 9568011: Unify Date.fromString and support more Iso 8601. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve parseInt. 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
« no previous file with comments | « no previous file | frog/leg/lib/js_helper.dart » ('j') | frog/leg/lib/mockimpl.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4
5 String fourDigits(int n) {
6 int absN = n.abs();
7 String sign = n < 0 ? "-" : "";
8 if (absN >= 1000) return "$n";
9 if (absN >= 100) return "${sign}0$absN";
10 if (absN >= 10) return "${sign}00$absN";
11 if (absN >= 1) return "${sign}000$absN";
12 }
13
5 String threeDigits(int n) { 14 String threeDigits(int n) {
6 if (n >= 100) return "${n}"; 15 if (n >= 100) return "${n}";
7 if (n > 10) return "0${n}"; 16 if (n > 10) return "0${n}";
8 return "00${n}"; 17 return "00${n}";
9 } 18 }
10 19
11 String twoDigits(int n) { 20 String twoDigits(int n) {
12 if (n >= 10) return "${n}"; 21 if (n >= 10) return "${n}";
13 return "0${n}"; 22 return "0${n}";
14 } 23 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/lib/js_helper.dart » ('j') | frog/leg/lib/mockimpl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698