Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/india_api/internal/inputs/indiadb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ def get_actual_wind_power_production_for_location(

def get_wind_regions(self) -> list[str]:
"""Gets the valid wind regions."""
return ["ruvnl"]
return ["rajasthan"]

def get_solar_regions(self) -> list[str]:
"""Gets the valid solar regions."""
return ["ruvnl"]
return ["rajasthan"]

def get_sites(self, email: str) -> list[internal.Site]:
"""Get a list of sites"""
Expand Down
4 changes: 2 additions & 2 deletions src/india_api/internal/inputs/indiadb/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def sites(db_session):
asset_type="pv",
country="india",
region="testID",
client_site_name="ruvnl_pv_testID1",
client_site_name="rajasthan_pv_testID1",
)
db_session.add(site)
sites.append(site)
Expand All @@ -82,7 +82,7 @@ def sites(db_session):
asset_type="wind",
country="india",
region="testID",
client_site_name="ruvnl_wind_testID",
client_site_name="rajasthan_wind_testID",
)
db_session.add(site)
sites.append(site)
Expand Down
4 changes: 2 additions & 2 deletions src/india_api/internal/inputs/indiadb/test_indiadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ def test_get_actual_solar_power_production_for_location(self, client, generation
def test_get_wind_regions(self, client) -> None:
result = client.get_wind_regions()
assert len(result) == 1
assert result[0] == "ruvnl"
assert result[0] == "rajasthan"

def test_get_solar_regions(self, client) -> None:
result = client.get_solar_regions()
assert len(result) == 1
assert result[0] == "ruvnl"
assert result[0] == "rajasthan"

def test_get_sites(self, client, sites) -> None:
sites_from_api = client.get_sites(email="test@test.com")
Expand Down
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.