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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | frog/leg/lib/js_helper.dart » ('j') | frog/leg/lib/mockimpl.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/lib/date_helper.dart
diff --git a/frog/leg/lib/date_helper.dart b/frog/leg/lib/date_helper.dart
index 9c19ac66ac2a579df578a3155b076de40a243f11..630d8fc3414ee08086b7a8db30c066d0768b6f38 100644
--- a/frog/leg/lib/date_helper.dart
+++ b/frog/leg/lib/date_helper.dart
@@ -2,6 +2,15 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+String fourDigits(int n) {
+ int absN = n.abs();
+ String sign = n < 0 ? "-" : "";
+ if (absN >= 1000) return "$n";
+ if (absN >= 100) return "${sign}0$absN";
+ if (absN >= 10) return "${sign}00$absN";
+ if (absN >= 1) return "${sign}000$absN";
+}
+
String threeDigits(int n) {
if (n >= 100) return "${n}";
if (n > 10) return "0${n}";
« 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