Skip to content

Commit

Permalink
Merge pull request #100 from ClubInfoInsaT/fix-98
Browse files Browse the repository at this point in the history
fix(planex): crash when inspecting a class
  • Loading branch information
ignyx authored Sep 3, 2024
2 parents 6ced28a + 7e29358 commit 43d1dde
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
12 changes: 12 additions & 0 deletions src/managers/DateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,16 @@ export default class DateManager {
this.monthsOfYear[date.getMonth()]
} ${date.getFullYear()}`;
}

/**
* Gets a translated string representing the given date.
*
* @param date The date objeect
* @return {string} The translated string
*/
getTranslatedDateFromDate(date: Date): string {
return `${this.daysOfWeek[date.getDay()]} ${date.getDate()} ${
this.monthsOfYear[date.getMonth()]
} ${date.getFullYear()}`;
}
}
18 changes: 9 additions & 9 deletions src/screens/Planex/PlanexScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { StyleSheet, View } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import Autolink from 'react-native-autolink';
import AlertDialog from '../../components/Dialogs/AlertDialog';
import { dateToString, getTimeOnlyString } from '../../utils/Planning';
import { dateToTimeString } from '../../utils/Planning';
import DateManager from '../../managers/DateManager';
import type { PlanexGroupType } from './GroupSelectionScreen';
import { MASCOT_STYLE } from '../../components/Mascot/Mascot';
Expand Down Expand Up @@ -146,15 +146,15 @@ function PlanexScreen() {
title: string;
color: string;
} = JSON.parse(event.nativeEvent.data);
const startDate = dateToString(new Date(data.start), true);
const endDate = dateToString(new Date(data.end), true);
const startString = getTimeOnlyString(startDate);
const endString = getTimeOnlyString(endDate);
console.log(data);
const start = new Date(data.start);
const startTime = dateToTimeString(start, true);
const endTime = dateToTimeString(new Date(data.end), true);

let msg = `${DateManager.getInstance().getTranslatedDate(startDate)}\n`;
if (startString != null && endString != null) {
msg += `${startString} - ${endString}`;
}
let msg = `${DateManager.getInstance().getTranslatedDateFromDate(
start
)}\n`;
msg += `${startTime} - ${endTime}`;
showDialog(data.title, msg, data.color);
}
};
Expand Down

0 comments on commit 43d1dde

Please sign in to comment.