| OLD | NEW |
| 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 | 4 |
| 5 // TODO(jmesserly): the native class should be the real JS Date. | 5 // TODO(jmesserly): the native class should be the real JS Date. |
| 6 // TODO(jimhug): Making the date value non-lazy might be a good path there. | 6 // TODO(jimhug): Making the date value non-lazy might be a good path there. |
| 7 class DateImplementation implements Date { | 7 class DateImplementation implements Date { |
| 8 final int value; | 8 final int value; |
| 9 final TimeZone timeZone; | 9 final TimeZone timeZone; |
| 10 | 10 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 String fourDigits(int n) { | 196 String fourDigits(int n) { |
| 197 int absN = n.abs(); | 197 int absN = n.abs(); |
| 198 String sign = n < 0 ? "-" : ""; | 198 String sign = n < 0 ? "-" : ""; |
| 199 if (absN >= 1000) return "$n"; | 199 if (absN >= 1000) return "$n"; |
| 200 if (absN >= 100) return "${sign}0$absN"; | 200 if (absN >= 100) return "${sign}0$absN"; |
| 201 if (absN >= 10) return "${sign}00$absN"; | 201 if (absN >= 10) return "${sign}00$absN"; |
| 202 if (absN >= 1) return "${sign}000$absN"; | 202 if (absN >= 1) return "${sign}000$absN"; |
| 203 } | 203 } |
| 204 String threeDigits(int n) { | 204 String threeDigits(int n) { |
| 205 if (n >= 100) return "${n}"; | 205 if (n >= 100) return "${n}"; |
| 206 if (n > 10) return "0${n}"; | 206 if (n >= 10) return "0${n}"; |
| 207 return "00${n}"; | 207 return "00${n}"; |
| 208 } | 208 } |
| 209 String twoDigits(int n) { | 209 String twoDigits(int n) { |
| 210 if (n >= 10) return "${n}"; | 210 if (n >= 10) return "${n}"; |
| 211 return "0${n}"; | 211 return "0${n}"; |
| 212 } | 212 } |
| 213 | 213 |
| 214 String y = fourDigits(year); | 214 String y = fourDigits(year); |
| 215 String m = twoDigits(month); | 215 String m = twoDigits(month); |
| 216 String d = twoDigits(day); | 216 String d = twoDigits(day); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 return isUtc == other.isUtc; | 285 return isUtc == other.isUtc; |
| 286 } | 286 } |
| 287 | 287 |
| 288 String toString() { | 288 String toString() { |
| 289 if (isUtc) return "TimeZone (UTC)"; | 289 if (isUtc) return "TimeZone (UTC)"; |
| 290 return "TimeZone (Local)"; | 290 return "TimeZone (Local)"; |
| 291 } | 291 } |
| 292 | 292 |
| 293 final bool isUtc; | 293 final bool isUtc; |
| 294 } | 294 } |
| OLD | NEW |