Skip to content

Commit

Permalink
📦 NEW: First version
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Apr 24, 2020
1 parent f8e79d8 commit 5eaea8a
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 10 deletions.
182 changes: 182 additions & 0 deletions data/lahore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
[
{
"no": "#1",
"date": "2020-04-25",
"sehar": "3:55 AM",
"iftar": "6:40 PM"
},
{
"no": "#2",
"date": "2020-04-26",
"sehar": "3:54 AM",
"iftar": "6:40 PM"
},
{
"no": "#3",
"date": "2020-04-27",
"sehar": "3:52 AM",
"iftar": "6:41 PM"
},
{
"no": "#4",
"date": "2020-04-28",
"sehar": "3:51 AM",
"iftar": "6:42 PM"
},
{
"no": "#5",
"date": "2020-04-29",
"sehar": "3:50 AM",
"iftar": "6:43 PM"
},
{
"no": "#6",
"date": "2020-04-30",
"sehar": "3:49 AM",
"iftar": "6:43 PM"
},
{
"no": "#7",
"date": "2020-05-01",
"sehar": "3:47 AM",
"iftar": "6:44 PM"
},
{
"no": "#8",
"date": "2020-05-02",
"sehar": "3:46 AM",
"iftar": "6:45 PM"
},
{
"no": "#9",
"date": "2020-05-03",
"sehar": "3:45 AM",
"iftar": "6:45 PM"
},
{
"no": "#10",
"date": "2020-05-04",
"sehar": "3:44 AM",
"iftar": "6:46 PM"
},
{
"no": "#11",
"date": "2020-05-05",
"sehar": "3:43 AM",
"iftar": "6:47 PM"
},
{
"no": "#12",
"date": "2020-05-06",
"sehar": "3:41 AM",
"iftar": "6:47 PM"
},
{
"no": "#13",
"date": "2020-05-07",
"sehar": "3:40 AM",
"iftar": "6:48 PM"
},
{
"no": "#14",
"date": "2020-05-08",
"sehar": "3:39 AM",
"iftar": "6:49 PM"
},
{
"no": "#15",
"date": "2020-05-09",
"sehar": "3:38 AM",
"iftar": "6:50 PM"
},
{
"no": "#16",
"date": "2020-05-10",
"sehar": "3:37 AM",
"iftar": "6:50 PM"
},
{
"no": "#17",
"date": "2020-05-11",
"sehar": "3:36 AM",
"iftar": "6:51 PM"
},
{
"no": "#18",
"date": "2020-05-12",
"sehar": "3:35 AM",
"iftar": "6:52 PM"
},
{
"no": "#19",
"date": "2020-05-13",
"sehar": "3:34 AM",
"iftar": "6:52 PM"
},
{
"no": "#20",
"date": "2020-05-14",
"sehar": "3:33 AM",
"iftar": "6:53 PM"
},
{
"no": "#21",
"date": "2020-05-15",
"sehar": "3:32 AM",
"iftar": "6:54 PM"
},
{
"no": "#22",
"date": "2020-05-16",
"sehar": "3:31 AM",
"iftar": "6:54 PM"
},
{
"no": "#23",
"date": "2020-05-17",
"sehar": "3:30 AM",
"iftar": "6:55 PM"
},
{
"no": "#24",
"date": "2020-05-18",
"sehar": "3:29 AM",
"iftar": "6:56 PM"
},
{
"no": "#25",
"date": "2020-05-19",
"sehar": "3:29 AM",
"iftar": "6:56 PM"
},
{
"no": "#26",
"date": "2020-05-20",
"sehar": "3:28 AM",
"iftar": "6:57 PM"
},
{
"no": "#27",
"date": "2020-05-21",
"sehar": "3:27 AM",
"iftar": "6:58 PM"
},
{
"no": "#28",
"date": "2020-05-22",
"sehar": "3:26 AM",
"iftar": "6:58 PM"
},
{
"no": "#29",
"date": "2020-05-23",
"sehar": "3:25 AM",
"iftar": "6:59 PM"
},
{
"no": "#30",
"date": "2020-05-24",
"sehar": "3:25 AM",
"iftar": "7:00 PM"
}
]
27 changes: 24 additions & 3 deletions index.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
#!/usr/bin/env node

const ora = require('ora');
const spinner = ora({text: ''});
// const {green, yellow, hex} = require('chalk');
const chalk = require('chalk');
const sym = require('log-symbols');
const cli = require('./utils/cli.js');
const init = require('./utils/init.js');
const to = require('await-to-js').default;
const theEnd = require('./utils/theEnd.js');
const handleError = require('cli-handle-error');
const data = require('./data/lahore.json');
const dateDiff = require('./utils/dateDiff');
const Table = require('cli-table3');
const green = string => chalk.hex(`#81EF96`)(string);

// CLI.
const [input] = cli.input;
const option = cli.flags.option;

(async () => {
init();
const firstRoza = '2020-04-25';
const today = new Date().toISOString().substring(0, 10);
const rozaNumber = dateDiff(firstRoza, '2020-06-10');
if (rozaNumber > 30) {
console.log(
`${sym.success} Eid Mubarak.\nRamadan is already over. Hope you had a fun time on Eid.\n`
);
} else {
const roza = rozaNumber > 1 ? data[rozaNumber] : data[0];

const table = new Table({
head: [green('Roza'), green('Sehar'), green('Iftar')]
});

table.push([roza.no, roza.sehar, roza.iftar]);
console.log(table.toString());
}
theEnd();
})();
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ramadan-cli",
"version": "0.0.1",
"description": "CLI to check Sehar and Iftar times in Ramadan.",
"description": "Check Sehar and Iftar times in Ramadan within your terminal.",
"license": "MIT",
"repository": "ahmadawais/ramadan-cli",
"author": {
Expand Down Expand Up @@ -42,7 +42,6 @@
"cli-handle-unhandled": "^1.1.0",
"cli-welcome": "^1.4.0",
"meow": "^6.1.0",
"ora": "^4.0.4",
"update-notifier": "^4.1.0"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ramadan-cli

[![DOWNLOADS](https://img.shields.io/npm/dt/ramadan-cli?label=DOWNLOADS%20%20❯&colorA=6A788D&colorB=6A788D&style=flat)](https://www.npmjs.com/package/ramadan-cli) [![Learn VSCode](https://img.shields.io/badge/-VSCODE.pro%20%E2%86%92-gray.svg?colorB=6A788D&style=flat)](https://VSCode.pro/?utm_source=GitHubFOSS)
[![DOWNLOADS](https://img.shields.io/npm/dt/{{name}}?label=DOWNLOADS%20%20❯&colorA=6A788D&colorB=6A788D&style=flat)](https://www.npmjs.com/package/{{name}}) [![Node.js CLI](https://img.shields.io/badge/-NodeCLI.com-gray.svg?colorB=6A788D&style=flat)](https://NodeCLI.com/?utm_source=FOSS) [![Learn VSCode](https://img.shields.io/badge/-VSCODE.pro-gray.svg?colorB=6A788D&style=flat)](https://VSCode.pro/?utm_source=FOSS) [![Sponsor](https://img.shields.io/badge/-Sponsor-gray.svg?colorB=6A788D&style=flat)](https://github.com/ahmadawais/sponsor?utm_source=FOSS)
[![Follow @MrAhmadAwais on Twitter](https://img.shields.io/badge/FOLLOW%20@MRAHMADAWAIS%20%E2%86%92-gray.svg?colorA=6A788D&colorB=6A788D&style=flat)](https://twitter.com/mrahmadawais/)

> CLI to check Sehar and Iftar times in Ramadan.
Expand Down
7 changes: 7 additions & 0 deletions utils/dateDiff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = (first, second) => {
// Take the difference between the dates and divide by milliseconds per day.
// Round to nearest whole number to deal with DST.
return Math.round(
(new Date(second) - new Date(first)) / (1000 * 60 * 60 * 24)
);
};
4 changes: 2 additions & 2 deletions utils/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = async () => {
unhandledError();
checkNode(`12`);
welcome(`ramadan-cli`, `by Awais.dev\n${pkgJSON.description}`, {
bgColor: `#007C91`,
bgColor: `#81EF96`,
color: `#FFFFFF`,
bold: true,
clear: true,
Expand All @@ -18,5 +18,5 @@ module.exports = async () => {
pkg: pkgJSON,
shouldNotifyInNpmScript: true,
updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week.
}).notify({ isGlobal: true });
}).notify({isGlobal: true});
};
10 changes: 8 additions & 2 deletions utils/theEnd.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
const sym = require('log-symbols');
const chalk = require('chalk');
const {dim} = require('chalk');

module.exports = async () => {
console.log(`${sym.success} All done.\n`);
console.log(
`\n${sym.success} ${dim(
`Star the repo for updates → https://git.io/ramadan-cli`
)}\n${sym.info} ${dim(
`Follow for more CLIs → https://twitter.com/MrAhmadAwais\n\n`
)}`
);
};

0 comments on commit 5eaea8a

Please sign in to comment.