OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/ftp/ftp_util.h" | 5 #include "net/ftp/ftp_util.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 if (!ThreeLetterMonthToNumber(month, &time_exploded.month)) | 156 if (!ThreeLetterMonthToNumber(month, &time_exploded.month)) |
157 return false; | 157 return false; |
158 | 158 |
159 if (!base::StringToInt(day, &time_exploded.day_of_month)) | 159 if (!base::StringToInt(day, &time_exploded.day_of_month)) |
160 return false; | 160 return false; |
161 | 161 |
162 if (!base::StringToInt(rest, &time_exploded.year)) { | 162 if (!base::StringToInt(rest, &time_exploded.year)) { |
163 // Maybe it's time. Does it look like time (HH:MM)? | 163 // Maybe it's time. Does it look like time (HH:MM)? |
164 if (rest.length() == 5 && rest[2] == ':') { | 164 if (rest.length() == 5 && rest[2] == ':') { |
165 if (!base::StringToInt(rest.substr(0, 2), &time_exploded.hour)) | 165 if (!base::StringToInt(rest.begin(), |
| 166 rest.begin() + 2, |
| 167 &time_exploded.hour)) |
166 return false; | 168 return false; |
167 | 169 |
168 if (!base::StringToInt(rest.substr(3, 2), &time_exploded.minute)) | 170 if (!base::StringToInt(rest.begin() + 3, |
| 171 rest.begin() + 5, |
| 172 &time_exploded.minute)) |
169 return false; | 173 return false; |
170 } else if (rest.length() == 4 && rest[1] == ':') { | 174 } else if (rest.length() == 4 && rest[1] == ':') { |
171 // Sometimes it's just H:MM. | 175 // Sometimes it's just H:MM. |
172 if (!base::StringToInt(rest.substr(0, 1), &time_exploded.hour)) | 176 if (!base::StringToInt(rest.begin(), |
| 177 rest.begin() + 1, |
| 178 &time_exploded.hour)) |
173 return false; | 179 return false; |
174 | 180 |
175 if (!base::StringToInt(rest.substr(2, 2), &time_exploded.minute)) | 181 if (!base::StringToInt(rest.begin() + 2, |
| 182 rest.begin() + 4, |
| 183 &time_exploded.minute)) |
176 return false; | 184 return false; |
177 } else { | 185 } else { |
178 return false; | 186 return false; |
179 } | 187 } |
180 | 188 |
181 // Guess the year. | 189 // Guess the year. |
182 base::Time::Exploded current_exploded; | 190 base::Time::Exploded current_exploded; |
183 current_time.LocalExplode(¤t_exploded); | 191 current_time.LocalExplode(¤t_exploded); |
184 | 192 |
185 // If it's not possible for the parsed date to be in the current year, | 193 // If it's not possible for the parsed date to be in the current year, |
(...skipping 25 matching lines...) Expand all Loading... |
211 while (pos < text.length() && !isspace(text[pos])) | 219 while (pos < text.length() && !isspace(text[pos])) |
212 pos++; | 220 pos++; |
213 } | 221 } |
214 | 222 |
215 string16 result(text.substr(pos)); | 223 string16 result(text.substr(pos)); |
216 TrimWhitespace(result, TRIM_ALL, &result); | 224 TrimWhitespace(result, TRIM_ALL, &result); |
217 return result; | 225 return result; |
218 } | 226 } |
219 | 227 |
220 } // namespace | 228 } // namespace |
OLD | NEW |