All files / src/pages/AcquirerPortal/LegalDocuments publishedDate.ts

100% Statements 2/2
100% Branches 1/1
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15                    68x     41x  
import { formatToUTC } from "@utils/date.helpers";
 
/**
 * legal_document_versions.published_at is a CALENDAR DATE, not an instant: the
 * publish modal sends the picked day as plain "YYYY-MM-DD" (PublishModal.tsx)
 * and the API stores it as midnight UTC. Format it in UTC — running it through
 * useFormatDateInTimezone (PLATFORM_TIMEZONE = America/New_York) shifts it to
 * the evening BEFORE, so a document published "Aug 18" renders as Aug 17 on
 * the documents list, the agreement modal, and the downloaded PDF.
 */
export const formatPublishedDate = (
  publishedDate: number | Date | string,
  format = "MM/dd/yyyy",
) => formatToUTC(publishedDate, format) as string;