Skip to content

Commit

Permalink
fix: timezone fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
domysh committed Sep 18, 2024
1 parent 6b7d5de commit cdaf0cf
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/components/Home/Jumbo.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const t = useTranslations(lang);
<p class="text-3xl md:text-4xl font-semibold">
{
WebsiteConfig.EVENT_START.toLocaleDateString(lang, {
timeZone: WebsiteConfig.EVENT_TIMEZONE,
day: "numeric",
month: "long",
year: "numeric",
Expand Down
5 changes: 3 additions & 2 deletions src/components/Schedule/Pages/ScheduleTab.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ScheduleDay } from "../../../data/types/sessionize";
import { getLangFromUrl } from "../../../i18n/utils";
import ScheduleCard from "../ScheduleCard.astro";
import { capitalizeFirstLetter } from "../../../react/utils";
import { WebsiteConfig } from "../../../config";
interface Props {
schedule: ScheduleDay[];
Expand Down Expand Up @@ -56,12 +57,12 @@ const calcSlotsTaken = (timeSlots, tsr, ts_idx) => {
const roomsSelected = rooms?s.rooms.filter((r) => rooms.includes(r.id)):s.rooms
const timeSlotSelected = s.timeSlots.filter((ts) => ts.rooms.some((tsr) => roomsSelected.map(r => r.id).includes(tsr.id)) || isServiceTimeSlot(ts));
const totalScheduleCols = roomsSelected.length;
const totalScheduleRows = timeSlotSelected.length;
let skipPadding: {[key:string]:number} = roomsSelected.map((room) => ({[room.id]:0})).reduce((a,b)=>({...a,...b}),{});
return <>
<div class="mb-5">
<p class="text-3xl font-bold mb-5">
{capitalizeFirstLetter(new Date(s.date).toLocaleDateString(lang, {
timeZone: WebsiteConfig.EVENT_TIMEZONE,
day: "numeric",
month: "long",
weekday: "long",
Expand Down Expand Up @@ -107,7 +108,7 @@ const calcSlotsTaken = (timeSlots, tsr, ts_idx) => {

return [
<div class="font-medium text-2xl">
<p>{ts.slotStart.substring(0, 5)}</p>
<p>{ts.slotStart}</p>
</div>,
...orderedSessions
];
Expand Down
4 changes: 4 additions & 0 deletions src/components/Sessions/Pages/SessionDetail.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import AddToCalendar from '../../Common/AddToCalendar.astro';
import BaseLayout from '../../Common/BaseLayout.astro';
import SessionTopic from '../SessionTopic.astro';
import { capitalizeFirstLetter } from "../../../react/utils";
import { WebsiteConfig } from '../../../config';
interface Props {
entry: SessionInfo;
Expand All @@ -32,16 +33,19 @@ const dateEnd = new Date(entry.endsAt);
const isScheduled = dateStart.getTime() != 0;
var date = capitalizeFirstLetter(dateStart.toLocaleDateString(lang, {
timeZone: WebsiteConfig.EVENT_TIMEZONE,
day: "numeric",
month: "short",
}));
const start = dateStart.toLocaleTimeString(lang, {
timeZone: WebsiteConfig.EVENT_TIMEZONE,
hour: "numeric",
minute: "numeric",
});
const end = dateEnd.toLocaleTimeString(lang, {
timeZone: WebsiteConfig.EVENT_TIMEZONE,
hour: "numeric",
minute: "numeric",
});
Expand Down
1 change: 1 addition & 0 deletions src/components/Speakers/Pages/SpeakerDetail.astro
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const pageTitle = `${speaker.fullName} @ ${WebsiteConfig.DEVFEST_NAME}`;
const dateEnd = new Date(session.endsAt);

const date = dateStart.toLocaleDateString(lang, {
timeZone: WebsiteConfig.EVENT_TIMEZONE,
month: "long",
day: "numeric",
});
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class WebsiteConfig {

public static readonly EVENT_START : Date = new Date('2024-10-26');
public static readonly EVENT_END : Date = new Date('2024-10-26');
public static readonly EVENT_TIMEZONE : string = 'Europe/Rome';
public static readonly EVENT_LOCATION_NAME : String = 'Polythecnic of Bari';
public static readonly EVENT_LOCATION_CITY : String = 'Bari';
public static readonly EVENT_LOCATION_ADDRESS : String = 'Via Edoardo Orabona 4';
Expand Down
16 changes: 10 additions & 6 deletions src/data/api/sessionize_api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WebsiteConfig } from "../../config";
import type { ScheduleDay, SessionInfo, Speaker } from "../types/sessionize";

const API_ID = "1rh747m6"
Expand All @@ -19,12 +20,15 @@ export async function getSchedule(): Promise<Promise<ScheduleDay[]>> {

schedule.forEach(
day => day.timeSlots.forEach(
slot => slot.rooms.forEach(
room => {
const sessionInfoFound = sessionsInfo.find((_s) => _s.id == room.session.id);
room.session.info = sessionInfoFound;
},
),
(slot, slot_idx) => {
day.timeSlots[slot_idx].slotStart = new Date(slot.rooms[0].session.startsAt).toLocaleString("it", {timeZone: WebsiteConfig.EVENT_TIMEZONE, hour:"numeric", minute:"numeric"})
slot.rooms.forEach(
room => {
const sessionInfoFound = sessionsInfo.find((_s) => _s.id == room.session.id);
room.session.info = sessionInfoFound;
},
)
}
),
);

Expand Down
1 change: 1 addition & 0 deletions src/pages/redirect/[url_encoded].astro
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const t = useTranslations(lang);
<p class="text-xl md:text-3xl font-semibold">
{
WebsiteConfig.EVENT_START.toLocaleDateString(lang, {
timeZone: WebsiteConfig.EVENT_TIMEZONE,
day: "numeric",
month: "long",
year: "numeric",
Expand Down
1 change: 1 addition & 0 deletions src/pages/ticket.astro
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { WebsiteConfig } from "../config"
<p class="text-3xl md:text-4xl font-semibold mt-5">
{
WebsiteConfig.EVENT_START.toLocaleDateString(lang, {
timeZone: WebsiteConfig.EVENT_TIMEZONE,
day: "numeric",
month: "long",
year: "numeric",
Expand Down
1 change: 1 addition & 0 deletions src/react/pages/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const LoginPage = () => {
<p className="text-2xl md:text-3xl font-semibold mt-5">
{
WebsiteConfig.EVENT_START.toLocaleDateString("en", {
timeZone: WebsiteConfig.EVENT_TIMEZONE,
day: "numeric",
month: "long",
year: "numeric",
Expand Down
1 change: 1 addition & 0 deletions src/react/pages/SignupPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const SignupPage = ({ token }: { token:string }) => {
<p className="text-2xl md:text-3xl font-semibold mt-5">
{
WebsiteConfig.EVENT_START.toLocaleDateString("en", {
timeZone: WebsiteConfig.EVENT_TIMEZONE,
day: "numeric",
month: "long",
year: "numeric",
Expand Down

0 comments on commit cdaf0cf

Please sign in to comment.