Skip to content

Commit

Permalink
Merge pull request #195 from gsainfoteam/timezone-issue-on-presentati…
Browse files Browse the repository at this point in the history
…on-layer
  • Loading branch information
2paperstar authored Nov 26, 2023
2 parents 2e217b6 + 9667988 commit 3da7341
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/app/[lng]/mypage/MypageTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const MypageTable = async ({
</div>
<div className="items-end justify-end">
<div className="text-regular m-5 text-secondaryText">
{dayjs(articleObj.createdAt).format('YYYY-MM-DD')}
{dayjs(articleObj.createdAt).tz().format('YYYY-MM-DD')}
</div>
</div>
</Link>
Expand Down
13 changes: 8 additions & 5 deletions src/app/[lng]/notice/[id]/AdditionalNotices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,29 @@ const AdditionalNotices = async ({
{t('zabo.additionalNotices.title')}
</p>
<p className="font-regular ml-2 text-base text-secondaryText">
{dayjs(content.createdAt).format('LLL')}
{dayjs(content.createdAt).tz().format('LLL')}
</p>
</div>

<div className="ml-8">
{index > 0 &&
dayjs(content.deadline).format('LLL') !==
dayjs(localeContents[index - 1].deadline).format('LLL') && (
!dayjs(content.deadline).isSame(
dayjs(localeContents[index - 1].deadline),
) && (
<div className="flex items-center gap-3">
<p className={'text-base font-bold'}>
{t('zabo.additionalNotices.deadlineChanged')}
</p>
<p className={'text-base font-medium text-secondaryText'}>
{dayjs(localeContents[index - 1].deadline).format('LLL')}
{dayjs(localeContents[index - 1].deadline)
.tz()
.format('LLL')}
</p>

<p></p>

<p className={'text-base font-medium'}>
{dayjs(content.deadline).format('LLL')}
{dayjs(content.deadline).tz().format('LLL')}
</p>
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/app/[lng]/notice/[id]/NoticeInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const NoticeInfo = async ({
<div>
{deadline && (
<>
<Deadline deadline={dayjs(deadline)} t={t} />
<Deadline deadline={dayjs(deadline).tz()} t={t} />
<div className="h-2" />
</>
)}
Expand Down Expand Up @@ -79,7 +79,7 @@ const Metadata = ({
<div className="h-5 w-0.5 bg-text dark:bg-secondaryText md:h-7" />
<div className="flex gap-4 font-normal text-secondaryText">
<Trans t={t} i18nKey="zabo.createdAt">
createdAt {{ createdAt: createdAt.format('LLL') }}
createdAt {{ createdAt: createdAt.tz().format('LLL') }}
</Trans>
{' · '}
<Trans t={t} i18nKey="zabo.views">
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/molecules/DDay/DDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const DDay = ({ deadline, t, className }: PropsWithT<DDayProps>) => (
].join(' ')}
>
<div className="text-sm font-bold text-white md:text-lg">
{ddayFormatted(dayjs(deadline), t)}
{ddayFormatted(dayjs(deadline).tz(), t)}
</div>
</div>
);
Expand Down
5 changes: 1 addition & 4 deletions src/app/components/organisms/Zabo/ImageZabo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Trans } from 'react-i18next';

import ZaboImage from '@/app/components/molecules/ZaboImage';
import { PropsWithLng } from '@/app/i18next';
import { useTranslation } from '@/app/i18next/client';
import getLocaleContents from '@/utils/getLocaleContents';

import DDay from '../../molecules/DDay';
Expand All @@ -21,8 +20,6 @@ const ImageZabo = <Origin extends ZaboOrigin>({
height,
lng,
}: ImageZaboProps<Origin> & PropsWithLng) => {
const { i18n } = useTranslation(lng);

const localContents = getLocaleContents(contents, lng);

const deadline = rawDeadline ? dayjs(rawDeadline) : undefined;
Expand Down Expand Up @@ -59,7 +56,7 @@ const ImageZabo = <Origin extends ZaboOrigin>({
</div>
<div className="flex text-sm font-medium text-secondaryText">
<Trans t={t} i18nKey="zabo.dateView">
{{ date: dayjs(createdAt).format('L') }}
{{ date: dayjs(createdAt).tz().format('L') }}
<strong className="font-bold"> · {{ views }}</strong>
</Trans>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/organisms/Zabo/TextZabo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import dayjs from 'dayjs';
import { Trans } from 'react-i18next';

import { PropsWithLng } from '@/app/i18next';
import { useTranslation } from '@/app/i18next/client';
import getLocaleContents from '@/utils/getLocaleContents';

import DDay from '../../molecules/DDay';
Expand Down Expand Up @@ -66,7 +65,7 @@ const TextZabo = <Origin extends ZaboOrigin>({
<div className="flex flex-col gap-2.5">
<div className="flex text-sm font-medium text-secondaryText">
<Trans t={t} i18nKey="zabo.dateView">
{{ date: dayjs(createdAt).format('L') }}
{{ date: dayjs(createdAt).tz().format('L') }}
<strong className="font-bold"> · {{ views }}</strong>
</Trans>
</div>
Expand Down
12 changes: 5 additions & 7 deletions src/app/components/templates/ResultZabo/ResultImageZabo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import { ResultImageZaboProps } from './ResultZabo';

const ResultImageZabo = async ({
contents,
createdAt: rawCreatedAt,
createdAt,
views,
author,
currentDeadline: rawDeadline,
currentDeadline,
tags,
searchQuery,

Expand All @@ -30,8 +30,6 @@ const ResultImageZabo = async ({

const localeContents = getLocaleContents(contents, lng);

const deadline = rawDeadline ? dayjs(rawDeadline) : undefined;
const createdAt = rawCreatedAt ? dayjs(rawCreatedAt) : undefined;
const title = localeContents[0].title;

return (
Expand All @@ -51,10 +49,10 @@ const ResultImageZabo = async ({
}}
>
<div className="align-start flex flex-col">
{deadline && (
{currentDeadline && (
<p className={'text-sm font-medium md:text-xl'}>
<Trans t={t} i18nKey="zabo.dueAt">
{{ dueAt: dayjs(deadline).format('LLL') }}
{{ dueAt: dayjs(currentDeadline).tz().format('LLL') }}
</Trans>
</p>
)}
Expand Down Expand Up @@ -88,7 +86,7 @@ const ResultImageZabo = async ({
<div className="flex gap-0.5">
<div className="flex text-sm font-medium text-secondaryText">
<Trans t={t} i18nKey="zabo.dateView">
{{ date: dayjs(createdAt).format('L') }}
{{ date: dayjs(createdAt).tz().format('L') }}
<strong className="font-bold"> · {{ views }}</strong>
</Trans>
</div>
Expand Down
10 changes: 4 additions & 6 deletions src/app/components/templates/ResultZabo/ResultTextZabo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ const ResultTextZabo = async ({
createdAt,
views,
author,
currentDeadline: rawDeadline,
currentDeadline,
tags,
searchQuery,

id,
lng,
}: ResultZaboProps) => {
const deadline = rawDeadline ? dayjs(rawDeadline) : undefined;

const { t } = await createTranslation(lng);
const localeContents = getLocaleContents(contents, lng);

Expand All @@ -41,10 +39,10 @@ const ResultTextZabo = async ({
}
>
<div className="flex flex-col items-start">
{deadline && (
{currentDeadline && (
<div className="mb-1.5 text-lg font-medium">
<Trans t={t} i18nKey="zabo.dueAt">
{{ dueAt: dayjs(deadline).format('LLL') }}
{{ dueAt: dayjs(currentDeadline).tz().format('LLL') }}
</Trans>
</div>
)}
Expand Down Expand Up @@ -81,7 +79,7 @@ const ResultTextZabo = async ({
<div className="flex gap-0.5">
<div className="flex text-sm font-medium text-secondaryText">
<Trans t={t} i18nKey="zabo.dateView">
{{ date: dayjs(createdAt).format('L') }}
{{ date: dayjs(createdAt).tz().format('L') }}
<strong className="font-bold"> · {{ views }}</strong>
</Trans>
</div>
Expand Down

0 comments on commit 3da7341

Please sign in to comment.