Skip to content

Commit

Permalink
Merge branch 'master' into IOPID-1298-stack-navigator-synch
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowsheep1 authored Jan 23, 2024
2 parents f25f714 + 3431429 commit 1a5189f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ts/features/walletV3/details/screens/WalletDetailsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from "../store";
import { walletDetailsGetInstrument } from "../store/actions";
import { UIWalletInfoDetails } from "../types/UIWalletInfoDetails";
import { getDateFromExpiryDate } from "../../../../utils/dates";

export type WalletDetailsScreenNavigationParams = Readonly<{
walletId: string;
Expand All @@ -46,7 +47,7 @@ const generateCardComponent = (details: UIWalletInfoDetails) => {
<PaymentCardBig
testID="CreditCardComponent"
cardType="CREDIT"
expirationDate={details.expiryDate}
expirationDate={getDateFromExpiryDate(details.expiryDate)}
holderName={details.holder || ""}
hpan={details.maskedPan || ""}
cardIcon={details.brand?.toLowerCase() as IOLogoPaymentExtType}
Expand Down
14 changes: 12 additions & 2 deletions ts/utils/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ export const isExpired = (
* @param expiryDate
*/
export const isExpiredDate = (expiryDate: string): boolean => {
const year = +expiryDate.slice(3, 5);
const month = +expiryDate.slice(0, 3);
const year = +expiryDate.slice(0, 4);
const month = +expiryDate.slice(4, 6);
const now = new Date();
const nowYearMonth = new Date(now.getFullYear(), now.getMonth() + 1);
const cardExpirationDate = new Date(year, month);
Expand Down Expand Up @@ -320,3 +320,13 @@ export const toAndroidCacheTimestamp = () =>
new Date(),
I18n.t("global.dateFormats.shortFormat").replace(/\//g, "")
);

/**
* This function returns a Date object from a string in format "YYYYMM"
* @param expiryDate
*/
export const getDateFromExpiryDate = (expiryDate: string): Date => {
const year = +expiryDate.slice(0, 4);
const month = +expiryDate.slice(4, 6);
return new Date(year, month - 1);
};

0 comments on commit 1a5189f

Please sign in to comment.