Skip to content

Commit

Permalink
Merge pull request #11 from quizer-app/develop
Browse files Browse the repository at this point in the history
Fix date formatting
  • Loading branch information
EloToJaa authored Jan 9, 2024
2 parents 3186baf + 44f5d02 commit 017cbf8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/api/types/quiz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type QuizResponse = {
averageRating: number;
numberOfRatings: number;
questions: QuestionResponse[];
createdAt: Date;
createdAt: string;
};

export type QuestionResponse = {
Expand Down
6 changes: 4 additions & 2 deletions src/utils/date.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export const formatDate = (date: Date): string => {
export const formatDate = (date: string): string => {
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;

const dateStringInUserTimeZone = date.toLocaleString("en-US", {
const dateObject = new Date(date);

const dateStringInUserTimeZone = dateObject.toLocaleString("en-US", {
timeZone: userTimeZone,
});

Expand Down

0 comments on commit 017cbf8

Please sign in to comment.