Skip to content

Commit

Permalink
add scopes india api
Browse files Browse the repository at this point in the history
  • Loading branch information
utsav-pal committed Feb 15, 2025
1 parent 206c51c commit 0934c64
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/india_api/internal/inputs/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime as dt
from zoneinfo import ZoneInfo # Available in Python 3.9 and later


def get_window() -> tuple[dt.datetime, dt.datetime]:
Expand All @@ -17,4 +18,28 @@ def get_window() -> tuple[dt.datetime, dt.datetime]:
second=0,
microsecond=0,
)
return (start, end)
return (start, end)

def get_forecast_deadline(forecast_date_str: str) -> str:
"""
Calculate the submission deadline for a given forecast date.
Args:
forecast_date_str (str): The forecast date in 'YYYY-MM-DD' format.
Returns:
str: The submission deadline in 'YYYY-MM-DD HH:MM IST' format.
"""
# Define the IST timezone
ist = ZoneInfo('Asia/Kolkata')

# Parse the input forecast date string into a datetime object
forecast_date = dt.datetime.strptime(forecast_date_str, '%Y-%m-%d')

# Calculate the deadline: 9:00 AM IST on the day before the forecast date
deadline = dt.datetime.combine(forecast_date - dt.timedelta(days=1), dt.time(9, 0), tzinfo=ist)

# Format the deadline as a string
deadline_str = deadline.strftime('%Y-%m-%d %H:%M %Z')

return deadline_str
Empty file.

0 comments on commit 0934c64

Please sign in to comment.