Skip to content

Commit 0934c64

Browse files
committed
add scopes india api
1 parent 206c51c commit 0934c64

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/india_api/internal/inputs/utils.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime as dt
2+
from zoneinfo import ZoneInfo # Available in Python 3.9 and later
23

34

45
def get_window() -> tuple[dt.datetime, dt.datetime]:
@@ -17,4 +18,28 @@ def get_window() -> tuple[dt.datetime, dt.datetime]:
1718
second=0,
1819
microsecond=0,
1920
)
20-
return (start, end)
21+
return (start, end)
22+
23+
def get_forecast_deadline(forecast_date_str: str) -> str:
24+
"""
25+
Calculate the submission deadline for a given forecast date.
26+
27+
Args:
28+
forecast_date_str (str): The forecast date in 'YYYY-MM-DD' format.
29+
30+
Returns:
31+
str: The submission deadline in 'YYYY-MM-DD HH:MM IST' format.
32+
"""
33+
# Define the IST timezone
34+
ist = ZoneInfo('Asia/Kolkata')
35+
36+
# Parse the input forecast date string into a datetime object
37+
forecast_date = dt.datetime.strptime(forecast_date_str, '%Y-%m-%d')
38+
39+
# Calculate the deadline: 9:00 AM IST on the day before the forecast date
40+
deadline = dt.datetime.combine(forecast_date - dt.timedelta(days=1), dt.time(9, 0), tzinfo=ist)
41+
42+
# Format the deadline as a string
43+
deadline_str = deadline.strftime('%Y-%m-%d %H:%M %Z')
44+
45+
return deadline_str

src/india_api/internal/service/routers/ruvnl.py

Whitespace-only changes.

0 commit comments

Comments
 (0)