timeconv#

This modules provides functions to convert between a datestring format and unixtime timestamp (double). The unixtimestamp is defined in seconds since 1970 UTC time. The datestring object will also be UTC by default.

Example usage#

https://mybinder.org/badge_logo.svg
# import this module
import time # default pyhon module
from themachinethatgoesping.tools import timeconv

unixtime   = time.time() # create a unixtimestamp in python
datestring = timeconv.unixtime_to_datestring(time.time()) # convert to datestring
print(datestring)

unixtime = timeconv.datestring_to_unixtime(datestring) # convert datestring to unixtimestamp
print(unixtime)

Format string#

date_string format#

Format

Meaning

%z:

zone (in hhmm (as hours/minuts east of utc)
z may only be at the beginning of the string!
If no z is given the string will be interpreted as utc 0

%d:

get_day as int dd

%m:

get_month as int mm

%b:

get_month as string bb

%Y:

get_year is int YYYY

%H:

hours as int HH

%M:

Minutes as int mm

%S:

Seconds as int SS

Functions (c++ module)#

# import this module
from themachinethatgoesping.tools import timeconv

This module extends the tools.timeconv with some functions implemented in pure python

datetime_to_datestring(dt: datetime, fractionalSecondsDigits: int = 0, format: str = '%z__%d-%m-%Y__%H:%M:%S') str#

Converting python datetime objects to datestrings

Parameters:
Returns:

DateString that fits to the specified format

Return type:

str

datestring_to_datetime(datestring: str, format: str = '%z__%d-%m-%Y__%H:%M:%S') datetime#

Converting date strings to python datetime objects

Parameters:
Returns:

python datetime object

Return type:

datetime

Functions (python extendet)#

# import this extended module
from themachinethatgoesping.tools import timeconv