aboutsummaryrefslogtreecommitdiff
path: root/diplomacy/utils/time.py
diff options
context:
space:
mode:
authorPhilip Paquette <pcpaquette@gmail.com>2019-09-11 12:58:45 -0400
committerPhilip Paquette <pcpaquette@gmail.com>2019-09-14 18:18:53 -0400
commitabb42dcd4886705d6ba8af27f68ef605218ac67c (patch)
tree9ae16f7a09fff539fa72e65198e284bca6ac3376 /diplomacy/utils/time.py
parenta954a00d263750c279dbb2c0a9ae85707022bcd7 (diff)
Added ReadtheDocs documentation for the public API
- Reformatted the docstring to be compatible - Added tests to make sure the documentation compiles properly - Added sphinx as a pip requirement Co-authored-by: Philip Paquette <pcpaquette@gmail.com> Co-authored-by: notoraptor <stevenbocco@gmail.com>
Diffstat (limited to 'diplomacy/utils/time.py')
-rw-r--r--diplomacy/utils/time.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/diplomacy/utils/time.py b/diplomacy/utils/time.py
index 6f250dd..9ac7edd 100644
--- a/diplomacy/utils/time.py
+++ b/diplomacy/utils/time.py
@@ -24,6 +24,7 @@ import pytz
def str_to_seconds(offset_str):
""" Converts a time in format 00W00D00H00M00S in number of seconds
+
:param offset_str: The string to convert (e.g. '20D')
:return: Its equivalent in seconds = 1728000
"""
@@ -47,6 +48,7 @@ def str_to_seconds(offset_str):
def trunc_time(timestamp, trunc_interval, time_zone='GMT'):
""" Truncates time at a specific interval (e.g. 20M) (i.e. Rounds to the next :20, :40, :60)
+
:param timestamp: The unix epoch to truncate (e.g. 1498746120)
:param trunc_interval: The truncation interval (e.g. 60*60 or '1H')
:param time_zone: The time to use for conversion (defaults to GMT otherwise)
@@ -65,6 +67,7 @@ def trunc_time(timestamp, trunc_interval, time_zone='GMT'):
def next_time_at(timestamp, time_at, time_zone='GMT'):
""" Returns the next timestamp at a specific 'hh:mm'
+
:param timestamp: The unix timestamp to convert
:param time_at: The next 'hh:mm' to have the time rounded to, or 0 to skip
:param time_zone: The time to use for conversion (defaults to GMT otherwise)