diff --git a/src/app/[slug]/page.tsx b/src/app/[slug]/page.tsx index 0b42fb43..a2afae47 100644 --- a/src/app/[slug]/page.tsx +++ b/src/app/[slug]/page.tsx @@ -13,6 +13,7 @@ import { website } from '@/config/website' import { getDrops } from '@/utils/getDrops' import { getNow } from '@/utils/getNow' import { getArweaves } from '@/utils/getArweaves' +import { getDropDate } from '@/utils/getDropDate' type Props = { params: { slug: string } @@ -137,8 +138,7 @@ export async function generateMetadata( async function getPartner(slug: string, spoofDate?: string) { const now = getNow(spoofDate) - - const today = format(now, 'yyyy-MM-dd') + const today = getDropDate(spoofDate) const date = Object.keys(schedule).find( (date) => schedule[date].slug === slug diff --git a/src/app/page.tsx b/src/app/page.tsx index 38737ca1..e65e9aee 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -19,6 +19,7 @@ import { RightArrow } from '@/components/icons/RightArrow' import { getTweets } from '@/utils/getTweets' import { getNow } from '@/utils/getNow' import { getArweaves } from '@/utils/getArweaves' +import { getDropDate } from '@/utils/getDropDate' type Props = { searchParams: { [key: string]: string | string[] | undefined } @@ -168,15 +169,12 @@ const INITIAL_TABS: TabsComponentProps = { async function getPageData(spoofDate?: string) { const now = getNow(spoofDate) - const today = format(now, 'yyyy-MM-dd') + const today = getDropDate(spoofDate) const featuredPartner = schedule[today] || schedule[Object.keys(schedule)[0]] const tabs: TabsComponentProps = Object.keys(schedule).reduce((acc, date) => { - const comparison = compareAsc( - now, - new Date(date).getTime() + 4 * 60 * 60 * 1000 - ) + const comparison = compareAsc(now, new Date(date).getTime()) const partner = schedule[date] if (comparison === 0 || typeof partner === 'undefined') { diff --git a/src/components/PartnerHero/PartnerHero.tsx b/src/components/PartnerHero/PartnerHero.tsx index b44a0721..445a3f2f 100644 --- a/src/components/PartnerHero/PartnerHero.tsx +++ b/src/components/PartnerHero/PartnerHero.tsx @@ -28,11 +28,6 @@ export const PartnerHero: FC = ({ teaser, customHeader, }) => { - const { isAfterEndDate, isBeforeStartDate } = getDateRangeValidation({ - startDate: headline.startDate, - endDate: headline.endDate, - }) - return (
diff --git a/src/utils/getDropDate.ts b/src/utils/getDropDate.ts new file mode 100644 index 00000000..54aafd79 --- /dev/null +++ b/src/utils/getDropDate.ts @@ -0,0 +1,17 @@ +import { getNow } from './getNow' + +const padNumber = (num: number) => { + return num < 10 ? `0${num}` : num +} + +export const getDropDate = (spoofDate?: string | null) => { + const now = getNow(spoofDate) + const date = new Date(now) + const year = date.getUTCFullYear() + const month = padNumber(date.getUTCMonth() + 1) + const hours = date.getUTCHours() + const day = hours >= 16 ? date.getUTCDate() : date.getUTCDate() - 1 + + const today = `${year}-${month}-${padNumber(day)}` + return today +} diff --git a/src/utils/getNow.ts b/src/utils/getNow.ts index d56a8693..5c1e73f0 100644 --- a/src/utils/getNow.ts +++ b/src/utils/getNow.ts @@ -13,17 +13,27 @@ const getSpoofDateFromParams = () => { export const getNow = (spoofDate?: string | null) => { const value = spoofDate || getSpoofDateFromParams() || defaultSpoofDate - const nowEST = new Date().getTime() - 4 * 60 * 60 * 1000 + const nowUTC = new Date().getTime() if (!ALLOW_SPOOFING) { - return nowEST + return nowUTC } const spoofedDate = value ? new Date(value) : undefined const isValidDate = isValid(spoofedDate) - const now = isValidDate && spoofedDate ? spoofedDate.getTime() : nowEST + if (isValidDate && spoofedDate) { + return Date.UTC( + spoofedDate.getFullYear(), + spoofedDate.getMonth(), + spoofedDate.getDate(), + spoofedDate.getHours(), + spoofedDate.getMinutes(), + spoofedDate.getSeconds(), + spoofedDate.getMilliseconds() + ) + } - return now + return nowUTC }