Skip to content

Commit

Permalink
tidy documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Aug 27, 2024
1 parent 23fed30 commit ad387d0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/anemoi/utils/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,19 @@ def print_dates(dates):


def frequency_to_string(frequency):
# TODO: use iso8601
"""Convert a frequency (i.e. a datetime.timedelta) to a string.
Parameters
----------
frequency : datetime.timedelta
The frequency to convert.
Returns
-------
str
A string representation of the frequency.
"""

frequency = frequency_to_timedelta(frequency)

total_seconds = frequency.total_seconds()
Expand Down Expand Up @@ -148,6 +160,7 @@ def frequency_to_timedelta(frequency):
----------
frequency : int or str or datetime.timedelta
The frequency to convert. If an integer, it is assumed to be in hours. If a string, it can be in the format:
- "1h" for 1 hour
- "1d" for 1 day
- "1m" for 1 minute
Expand All @@ -156,6 +169,8 @@ def frequency_to_timedelta(frequency):
- "1:30:10" for 1 hour, 30 minutes and 10 seconds
- "PT10M" for 10 minutes (ISO8601)
If a timedelta object is provided, it is returned as is.
Returns
-------
datetime.timedelta
Expand Down

0 comments on commit ad387d0

Please sign in to comment.