Skip to content

Commit

Permalink
👌 IMPROVE: Highlight today roza
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Apr 3, 2022
1 parent a934f96 commit e450e6e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const {school, all} = cli.flags;
init();
input === 'help' && (await cli.showHelp(0));
!input && (await cli.showHelp(0));

// replace all spaces with a - character
const city = input.toLowerCase().replace(/\s/g, "-").trim();
const city = input.toLowerCase().replace(/\s/g, '-').trim();

// → Set first ramazan date b3low.
await print({city, school, all, firstRozaDateISO: `2022-04-03`});
Expand Down
26 changes: 23 additions & 3 deletions utils/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@ module.exports = async ({city, school, all, firstRozaDateISO}) => {
spinner.start(`${y(`FETCHING`)} times …`);
const data = await getAll({city, school});
spinner.stop();
data.map(day =>
table.push([day.no, day.sehar, day.iftar, day.date])
);

data.map(day => {
if (isToday(day.date)) {
table.push([
green(day.no),
green(day.sehar),
green(day.iftar),
green(day.date)
]);
return;
}
table.push([day.no, day.sehar, day.iftar, day.date]);
});
}

if (single) {
Expand All @@ -46,3 +56,13 @@ module.exports = async ({city, school, all, firstRozaDateISO}) => {
console.log(table.toString());
}
};

function isToday(d) {
const date = DateTime.fromISO(d);
const today = DateTime.local();
return (
date.year === today.year &&
date.month === today.month &&
date.day === today.day
);
}

0 comments on commit e450e6e

Please sign in to comment.