| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 return AbbreviatedMonthsMap::GetInstance()->GetMonthNumber(text, number); | 196 return AbbreviatedMonthsMap::GetInstance()->GetMonthNumber(text, number); |
| 197 } | 197 } |
| 198 | 198 |
| 199 // static | 199 // static |
| 200 bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day, | 200 bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day, |
| 201 const string16& rest, | 201 const string16& rest, |
| 202 const base::Time& current_time, | 202 const base::Time& current_time, |
| 203 base::Time* result) { | 203 base::Time* result) { |
| 204 base::Time::Exploded time_exploded = { 0 }; | 204 base::Time::Exploded time_exploded = { 0 }; |
| 205 | 205 |
| 206 if (!AbbreviatedMonthToNumber(month, &time_exploded.month)) | 206 if (!AbbreviatedMonthToNumber(month, &time_exploded.month)) { |
| 207 return false; | 207 // Work around garbage sent by some servers in the same column |
| 208 // as the month. Take just last 3 characters of the string. |
| 209 if (month.length() < 3 || |
| 210 !AbbreviatedMonthToNumber(month.substr(month.length() - 3), |
| 211 &time_exploded.month)) { |
| 212 return false; |
| 213 } |
| 214 } |
| 208 | 215 |
| 209 if (!base::StringToInt(day, &time_exploded.day_of_month)) | 216 if (!base::StringToInt(day, &time_exploded.day_of_month)) |
| 210 return false; | 217 return false; |
| 211 if (time_exploded.day_of_month > 31) | 218 if (time_exploded.day_of_month > 31) |
| 212 return false; | 219 return false; |
| 213 | 220 |
| 214 if (!base::StringToInt(rest, &time_exploded.year)) { | 221 if (!base::StringToInt(rest, &time_exploded.year)) { |
| 215 // Maybe it's time. Does it look like time (HH:MM)? | 222 // Maybe it's time. Does it look like time (HH:MM)? |
| 216 if (rest.length() == 5 && rest[2] == ':') { | 223 if (rest.length() == 5 && rest[2] == ':') { |
| 217 if (!base::StringToInt(StringPiece16(rest.begin(), rest.begin() + 2), | 224 if (!base::StringToInt(StringPiece16(rest.begin(), rest.begin() + 2), |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 while (!iter.end() && !u_isspace(iter.get())) | 340 while (!iter.end() && !u_isspace(iter.get())) |
| 334 iter.Advance(); | 341 iter.Advance(); |
| 335 } | 342 } |
| 336 | 343 |
| 337 string16 result(text.substr(iter.array_pos())); | 344 string16 result(text.substr(iter.array_pos())); |
| 338 TrimWhitespace(result, TRIM_ALL, &result); | 345 TrimWhitespace(result, TRIM_ALL, &result); |
| 339 return result; | 346 return result; |
| 340 } | 347 } |
| 341 | 348 |
| 342 } // namespace | 349 } // namespace |
| OLD | NEW |