Skip to content

Commit

Permalink
Merge pull request #5 from suryavaddiraju/development
Browse files Browse the repository at this point in the history
Added Global UTC Support
  • Loading branch information
suryavaddiraju authored Apr 21, 2024
2 parents 05f2b7c + 4072549 commit 55fc42e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
28 changes: 14 additions & 14 deletions lib/time_work.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ function sleep(ms){
async function sleep_for_login(ticket_time){
if (ticket_time === 1 || ticket_time === 2){
if (ticket_time === 1){
const targetTime = new Date();
targetTime.setHours(9, 58, 0, 0); // Set target time to 09:58:00.000 AM
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(4, 28, 0, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
}
Expand All @@ -16,9 +16,9 @@ async function sleep_for_login(ticket_time){
}
}
else if (ticket_time === 2){
const targetTime = new Date();
targetTime.setHours(10, 58, 0, 0); // Set target time to 10:58:00.000 AM
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(5, 28, 0, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
}
Expand All @@ -38,17 +38,17 @@ async function sleep_for_login(ticket_time){
async function sleep_for_availability_check(ticket_time){
if (ticket_time === 1 || ticket_time === 2){
if (ticket_time === 1){
const targetTime = new Date();
targetTime.setHours(10, 0, 1, 0); // Set target time to 10:00:00.000 AM
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(4, 30, 1, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
}
}
if (ticket_time === 2){
const targetTime = new Date();
targetTime.setHours(11, 0, 1, 0); // Set target time to 11:00:00.000 AM
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(5, 30, 1, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
}
Expand All @@ -63,22 +63,22 @@ async function sleep_for_availability_check(ticket_time){
}
function start_before_3_minutes(ticket_time){
if (ticket_time === 1) {
const targetTime = new Date();
targetTime.setHours(9, 57, 0, 0);
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(4, 27, 0, 0);
if (currentTime < targetTime) {
throw new Error("Please Start the booking after 09:57:00.000 AM");
throw new Error("Please Start the booking after 09:57:00.000 AM IST");
}
else{
return "Proceeding to Book Tickets";
}
}
else if (ticket_time === 2) {
const targetTime = new Date();
targetTime.setHours(10, 57, 0, 0);
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(5, 27, 0, 0);
if (currentTime < targetTime) {
throw new Error("Please Start the booking after 10:57:00.000 AM");
throw new Error("Please Start the booking after 10:57:00.000 AM IST");
}
else{
return "Proceeding to Book Tickets";
Expand Down
2 changes: 1 addition & 1 deletion lib/workings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class IRCTC{
headers['spa-csrf-token'] = this.csrf_token;
headers.bmiyek = this.user_hash;
headers["Content-Length"] = postdata_string.length.toString();
await sleep(22000);
await sleep(21000);
const response = await this.axios_instance.post(
"https://www.irctc.co.in/eticketing/protected/mapps1/allLapAvlFareEnq/Y",
postdata_string,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "irctc-api",
"description": "A package built on top of IRCTC Website APIs to make train tickets , managing user profile faster and simpler. Currently this package only works on NodeJs environment and we were not recommending this to use on browser or any other Javascript environment.",
"version": "1.0.7",
"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": "1.0.8",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down

0 comments on commit 55fc42e

Please sign in to comment.