| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. All rights reserved. | 2 * Copyright 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style | 4 * Use of this source code is governed by a BSD-style |
| 5 * license that can be found in the LICENSE file or at | 5 * license that can be found in the LICENSE file or at |
| 6 * https://developers.google.com/open-source/licenses/bsd | 6 * https://developers.google.com/open-source/licenses/bsd |
| 7 */ | 7 */ |
| 8 part of charted.locale.format; | 8 part of charted.locale.format; |
| 9 | 9 |
| 10 typedef String TimeFormatFunction(DateTime date); | 10 typedef String TimeFormatFunction(DateTime date); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 DateTime parse(String string) { | 37 DateTime parse(String string) { |
| 38 assert(_dateFormat != null); | 38 assert(_dateFormat != null); |
| 39 return _dateFormat.parse(string); | 39 return _dateFormat.parse(string); |
| 40 } | 40 } |
| 41 | 41 |
| 42 TimeFormatFunction multi(List<List> formats) { | 42 TimeFormatFunction multi(List<List> formats) { |
| 43 var n = formats.length, i = -1; | 43 var n = formats.length, i = -1; |
| 44 while (++i < n) formats[i][0] = _getInstance(formats[i][0] as String); | 44 while (++i < n) formats[i][0] = _getInstance(formats[i][0] as String); |
| 45 return (var date) { | 45 return (var date) { |
| 46 if (date is num) { | 46 if (date is num) { |
| 47 date = new DateTime.fromMillisecondsSinceEpoch(date.toInt()); | 47 date = new DateTime.fromMillisecondsSinceEpoch((date as num).toInt()); |
| 48 } | 48 } |
| 49 var i = 0, f = formats[i]; | 49 var i = 0, f = formats[i]; |
| 50 while (f.length < 2 || f[1](date) == false) { | 50 while (f.length < 2 || f[1](date) == false) { |
| 51 i++; | 51 i++; |
| 52 if (i < n) f = formats[i]; | 52 if (i < n) f = formats[i]; |
| 53 } | 53 } |
| 54 if (i == n) return null; | 54 if (i == n) return null; |
| 55 return f[0].apply(date); | 55 return f[0].apply(date); |
| 56 }; | 56 }; |
| 57 } | 57 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 UTCTimeFormat _getInstance(String template) { | 120 UTCTimeFormat _getInstance(String template) { |
| 121 return new UTCTimeFormat(template, _locale); | 121 return new UTCTimeFormat(template, _locale); |
| 122 } | 122 } |
| 123 | 123 |
| 124 DateTime parse(String string) { | 124 DateTime parse(String string) { |
| 125 assert(_dateFormat != null); | 125 assert(_dateFormat != null); |
| 126 return _dateFormat.parseUTC(string); | 126 return _dateFormat.parseUTC(string); |
| 127 } | 127 } |
| 128 } | 128 } |
| OLD | NEW |