1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/autofill/ios/browser/credit_card_util.h"
7 #include "base/strings/sys_string_conversions.h"
8 #include "components/autofill/core/browser/autofill_type.h"
9 #include "components/autofill/core/browser/credit_card.h"
13 NSString* GetCreditCardName(const CreditCard& credit_card,
14 const std::string& locale) {
15 return base::SysUTF16ToNSString(credit_card.GetInfo(
16 autofill::AutofillType(autofill::CREDIT_CARD_NAME), locale));
19 NSString* GetCreditCardObfuscatedNumber(const CreditCard& credit_card) {
20 return base::SysUTF16ToNSString(credit_card.TypeAndLastFourDigits());
23 NSDateComponents* GetCreditCardExpirationDate(const CreditCard& credit_card) {
24 NSDateComponents* expiration_date =
25 [[[NSDateComponents alloc] init] autorelease];
26 expiration_date.year = credit_card.expiration_year();
27 expiration_date.month = credit_card.expiration_month();
28 return expiration_date;
31 BOOL IsCreditCardLocal(const CreditCard& credit_card) {
32 return credit_card.record_type() == autofill::CreditCard::LOCAL_CARD;
35 } // namespace autofill