Skip to content

Commit

Permalink
Fixed a indexing on month array, removed a var declaration, off-by-on…
Browse files Browse the repository at this point in the history
…e on date
  • Loading branch information
cdkostov committed May 10, 2024
1 parent 6290ba6 commit 4d8e50b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ const parseDateString = (str: string) => {
let min: string = str.slice(14, 16);

let hour_num = Number(hour);
let day_num = Number(day);
hour_num -= 7;

if (hour_num < 0) {
hour_num = 24 + hour_num;
day_num -= 1;
}

let ampm: string = 'XM';
Expand All @@ -29,9 +31,9 @@ const parseDateString = (str: string) => {
ampm = 'AM';
}

let time: string = String(hour_num) + ':' + min + ' ' + ampm;
let time: string = `${hour_num}:${min} ${ampm}`;

var monthNames = [
const monthNames = [
'January',
'February',
'March',
Expand All @@ -46,8 +48,8 @@ const parseDateString = (str: string) => {
'December',
];

let monthName = monthNames[Number(month)];
return monthName + ' ' + day + ', ' + year + ' at ' + time;
let monthName = monthNames[Number(month) - 1];
return `${monthName} ${day_num}, ${year} at ${time}`;
};

const Index = ({ articles }: Props) => {
Expand Down

0 comments on commit 4d8e50b

Please sign in to comment.