Skip to content

Commit

Permalink
Merge pull request #23 from suryavaddiraju/development
Browse files Browse the repository at this point in the history
Controlled Time
  • Loading branch information
suryavaddiraju committed May 9, 2024
2 parents 0200edb + c7231a5 commit fbd944c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ class IRCTC extends main_class{
super();
}
async book(params){
if (!params){
throw new Error("You have not set any parameters for booking. Please set the parameters.");
}
if (!(params.hasOwnProperty("log") && typeof params["log"] === 'boolean')){
console.log("You have not set any valid log parameter. Setting log to false.\nIf you need to set up logging, please set log parameter to true.");
params.log = false;
Expand Down
8 changes: 6 additions & 2 deletions lib/time_work.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ async function start_before_3_minutes(ticket_time){
const currentTime = new Date(date_time_string);
const targetTime = new Date(currentTime);
targetTime.setUTCHours(4, 27, 0, 0);
if (currentTime < targetTime) {
const stoptime = new Date(currentTime);
stoptime.setUTCHours(18, 30, 0, 0);
if (currentTime < targetTime || currentTime > stoptime) {
throw new Error("Please Start the booking after 09:57:00.000 AM IST");
}
else{
Expand All @@ -115,7 +117,9 @@ async function start_before_3_minutes(ticket_time){
const currentTime = new Date(date_time_string);
const targetTime = new Date(currentTime);
targetTime.setUTCHours(5, 27, 0, 0);
if (currentTime < targetTime) {
const stoptime = new Date(currentTime);
stoptime.setUTCHours(18, 30, 0, 0);
if (currentTime < targetTime || currentTime > stoptime) {
throw new Error("Please Start the booking after 10:57:00.000 AM IST");
}
else{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "irctc-api",
"description": "An exclusive NodeJs only package built on top of IRCTC Website APIs to book train tickets, managing user profile faster and simpler from anywhere in the world",
"version": "2.0.1",
"version": "2.0.2",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down

0 comments on commit fbd944c

Please sign in to comment.