Skip to content

Commit

Permalink
fix timezone #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabor Juhasz committed Jul 28, 2022
1 parent e7499fd commit 82db5a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
13 changes: 2 additions & 11 deletions components/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import { Favorites } from "pages";
import { FC } from "react";
import { Item } from "types";

import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";
dayjs.extend(utc);
dayjs.extend(timezone);

export const SCALE_MINUTES_TO_PIXELS = 3.8;

interface BoxProps {
Expand Down Expand Up @@ -103,13 +98,9 @@ export const Box: FC<BoxProps> = ({ item, startOfDay, favorites, setDetailId })
}}
>
<p>
<span>{dayjs(item.date).tz("Europe/Budapest").format("HH:mm")}</span>
<span>{dayjs(item.date).format("HH:mm")}</span>
<span style={{ paddingLeft: 4, paddingRight: 4 }}>-</span>
<span>
{dayjs(item.date + item.duration * 60 * 1000)
.tz("Europe/Budapest")
.format("HH:mm")}
</span>
<span>{dayjs(item.date + item.duration * 60 * 1000).format("HH:mm")}</span>
</p>
<p>{item.duration} perc</p>
</div>
Expand Down
13 changes: 2 additions & 11 deletions components/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import { Favorites, FavoriteState } from "pages";
import { FC } from "react";
import { Item } from "types";

import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";
dayjs.extend(utc);
dayjs.extend(timezone);

interface DetailProps {
item: Item;
favorites: Favorites;
Expand All @@ -33,13 +28,9 @@ export const Detail: FC<DetailProps> = ({ item, favorites, setFavoriteState }) =
}}
>
<p>
<span>{dayjs(item.date).tz("Europe/Budapest").format("HH:mm")}</span>
<span>{dayjs(item.date).format("HH:mm")}</span>
<span style={{ paddingLeft: 4, paddingRight: 4 }}>-</span>
<span>
{dayjs(item.date + item.duration * 60 * 1000)
.tz("Europe/Budapest")
.format("HH:mm")}
</span>
<span>{dayjs(item.date + item.duration * 60 * 1000).format("HH:mm")}</span>
</p>
<p>{item.duration} perc</p>
</div>
Expand Down
7 changes: 6 additions & 1 deletion pages/api/filter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { Day, Village, Topic, Item, Stage } from "types";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";

dayjs.extend(utc);
dayjs.extend(timezone);

const getUrl = (host?: string) => {
if (!host) {
Expand Down Expand Up @@ -33,7 +38,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
return item.time?.name;
})
.map((item) => {
item.date = new Date("2022 " + item.time?.name).getTime();
item.date = dayjs.tz("2022 " + item.time?.name, "Europe/Budapest").unix() * 1000;
item.dateInMinutes = item.date / 1000 / 60;
item.id = item.productionId + "_" + item.dateInMinutes;
return item;
Expand Down

1 comment on commit 82db5a9

@vercel
Copy link

@vercel vercel bot commented on 82db5a9 Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

katlan – ./

katlan-git-main-juhg24.vercel.app
katlan-juhg24.vercel.app
katlan.vercel.app

Please sign in to comment.