Skip to content

Commit

Permalink
Fix date offset in listing form creation
Browse files Browse the repository at this point in the history
  • Loading branch information
kaje94 committed Jan 2, 2024
1 parent 441a652 commit 3d00191
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Common/CookieConsent/CookieConsent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const CookieConsent = () => {
return (
<div
className={clsx(
"sticky bottom-0 flex w-full justify-center border-t-2 border-secondary bg-hero py-2 shadow-2xl",
"sticky bottom-0 z-10 flex w-full justify-center border-t-2 border-secondary bg-hero py-2",
isLandingPage ? "bg-hero" : "bg-neutral",
)}
>
Expand Down
12 changes: 10 additions & 2 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const isRenewableListing = (expiryDate: Date): boolean => {
return false;
};

/** Convert year into a date ISO string */
/** Convert year into a yyyy-mm-dd string */
export const convertYearToDateString = (year: string | number): string => {
const yearNumber = typeof year === "string" ? parseInt(year, 10) : year;

Expand All @@ -121,7 +121,15 @@ export const convertYearToDateString = (year: string | number): string => {
// Assuming January 1st of the given year
const date = new Date(yearNumber, 0, 1);

return date.toISOString();
// // Get the year, month, and day from the date object
const yyyy = date.getFullYear().toString().padStart(4, "0");
const mm = (date.getMonth() + 1).toString().padStart(2, "0");
const dd = date.getDate().toString().padStart(2, "0");

// Format the date as yyyy-mm-dd
const formattedDate = `${yyyy}-${mm}-${dd}`;

return formattedDate;
};

/** Convert a camel-case string into a non-camel case string */
Expand Down

0 comments on commit 3d00191

Please sign in to comment.