Skip to content

Commit

Permalink
Merge pull request #797 from Lunatic-Labs/SKIL-535
Browse files Browse the repository at this point in the history
SKIL-535
  • Loading branch information
aparriaran authored Dec 3, 2024
2 parents 675590a + b371190 commit aa5496e
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions FrontEndReact/src/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,37 +271,27 @@ export function getDueDateString(dueDate) {
}

export function getHumanReadableDueDate(dueDate, timeZone) {
dueDate = dueDate.substring(5);
const date = new Date(dueDate);

var month = Number(dueDate.substring(0, 2)) - 1;
const month = date.getMonth();

dueDate = dueDate.substring(3);
const day = date.getDate();

var day = Number(dueDate.substring(0, 2));

dueDate = dueDate.substring(3);

var hour = Number(dueDate.substring(0, 2));

var twelveHourClock = hour < 12 ? "am": "pm";

hour = hour > 12 ? (hour % 12) : hour;

hour = hour === 0 ? 12 : hour;

dueDate = dueDate.substring(3);

var minute = Number(dueDate.substring(0, 2));
const hour = date.getHours();

const minute = date.getMinutes();

const monthNames = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];

const twelveHourClock = hour < 12 ? "am": "pm";

var minutesString = minute < 10 ? ("0" + minute): minute;

var timeString = `${hour}:${minutesString}${twelveHourClock}`;

var dueDateString = `${monthNames[month]} ${day} at ${timeString} ${timeZone ? timeZone : ""}`;

return dueDateString;
const displayHour = hour > 12 ? (hour % 12) : (hour === 0 ? 12 : hour);
const minutesString = minute < 10 ? ("0" + minute): minute;
const timeString = `${displayHour}:${minutesString}${twelveHourClock}`;
return `${monthNames[month]} ${day} at ${timeString} ${timeZone ? timeZone : ""}`;
}

/**
Expand Down

0 comments on commit aa5496e

Please sign in to comment.