| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/validation.h" | 5 #include "components/autofill/core/browser/validation.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 int cc_month; | 33 int cc_month; |
| 34 if (!base::StringToInt(month_cleaned, &cc_month)) | 34 if (!base::StringToInt(month_cleaned, &cc_month)) |
| 35 return false; | 35 return false; |
| 36 | 36 |
| 37 return IsValidCreditCardExpirationDate(cc_year, cc_month, now); | 37 return IsValidCreditCardExpirationDate(cc_year, cc_month, now); |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool IsValidCreditCardExpirationDate(int year, | 40 bool IsValidCreditCardExpirationDate(int year, |
| 41 int month, | 41 int month, |
| 42 const base::Time& now) { | 42 const base::Time& now) { |
| 43 if (month < 1 || month > 12) |
| 44 return false; |
| 45 |
| 43 base::Time::Exploded now_exploded; | 46 base::Time::Exploded now_exploded; |
| 44 now.LocalExplode(&now_exploded); | 47 now.LocalExplode(&now_exploded); |
| 45 | 48 |
| 46 if (year < now_exploded.year) | 49 if (year < now_exploded.year) |
| 47 return false; | 50 return false; |
| 48 | 51 |
| 49 if (year == now_exploded.year && month < now_exploded.month) | 52 if (year == now_exploded.year && month < now_exploded.month) |
| 50 return false; | 53 return false; |
| 51 | 54 |
| 52 return true; | 55 return true; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 number_string.begin() + 9), | 204 number_string.begin() + 9), |
| 202 &serial) | 205 &serial) |
| 203 || serial == 0) { | 206 || serial == 0) { |
| 204 return false; | 207 return false; |
| 205 } | 208 } |
| 206 | 209 |
| 207 return true; | 210 return true; |
| 208 } | 211 } |
| 209 | 212 |
| 210 } // namespace autofill | 213 } // namespace autofill |
| OLD | NEW |