Spaces:
Sleeping
Sleeping
kadjb
Browse files
utils.py
CHANGED
|
@@ -28,13 +28,13 @@ def get_competitions(CONFIG_URL):
|
|
| 28 |
|
| 29 |
def get_latest_evaluation_time(evaluation_times):
|
| 30 |
"""
|
| 31 |
-
Get the latest UTC evaluation time as a
|
| 32 |
|
| 33 |
Args:
|
| 34 |
evaluation_times (list): List of evaluation times as strings (in HH:MM format).
|
| 35 |
|
| 36 |
Returns:
|
| 37 |
-
|
| 38 |
"""
|
| 39 |
|
| 40 |
# Get the current UTC date and time
|
|
@@ -50,8 +50,9 @@ def get_latest_evaluation_time(evaluation_times):
|
|
| 50 |
# Loop through the evaluation times in reverse to find the latest time that has passed
|
| 51 |
for eval_time in reversed(eval_times):
|
| 52 |
if current_utc_time >= eval_time:
|
| 53 |
-
# If the time has passed today, return today's date with that time
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
# If none of the evaluation times have passed, return the latest one from the previous day
|
| 57 |
yesterday = current_utc_datetime - timedelta(days=1)
|
|
|
|
| 28 |
|
| 29 |
def get_latest_evaluation_time(evaluation_times):
|
| 30 |
"""
|
| 31 |
+
Get the latest UTC evaluation time as a pandas Timestamp (with dtype=datetime64[ns, UTC]).
|
| 32 |
|
| 33 |
Args:
|
| 34 |
evaluation_times (list): List of evaluation times as strings (in HH:MM format).
|
| 35 |
|
| 36 |
Returns:
|
| 37 |
+
pd.Timestamp: Latest evaluation time as a pandas Timestamp with timezone UTC.
|
| 38 |
"""
|
| 39 |
|
| 40 |
# Get the current UTC date and time
|
|
|
|
| 50 |
# Loop through the evaluation times in reverse to find the latest time that has passed
|
| 51 |
for eval_time in reversed(eval_times):
|
| 52 |
if current_utc_time >= eval_time:
|
| 53 |
+
# If the time has passed today, return today's date with that time as pd.Timestamp
|
| 54 |
+
latest_time = current_utc_datetime.replace(hour=eval_time.hour, minute=eval_time.minute, second=0, microsecond=0)
|
| 55 |
+
return pd.Timestamp(latest_time, tz='UTC')
|
| 56 |
|
| 57 |
# If none of the evaluation times have passed, return the latest one from the previous day
|
| 58 |
yesterday = current_utc_datetime - timedelta(days=1)
|