Date and Time

Date

class gd.datetime.date[source]

DateTime

class gd.datetime.datetime[source]
classmethod from_human_delta(string: str, simple: bool = True)DT[source]

Convert human time delta to datetime object.

Parameters
  • string (str) – Human time delta, like 13 hours ago or in 42 seconds.

  • simple (bool) – Whether to parse simple delta, or complex one. Note that complex version can parse simple strings, but not vice-versa. See to_human_delta`() for more information.

Returns

Datetime object from string.

Return type

gd.datetime.datetime

to_human_delta(distance_only: bool = False, simple: bool = True)str[source]

Convert datetime object to human delta.

Parameters
  • self (Optional[gd.datetime.datetime]) – Datetime object to convert to string. If None, unknown is used.

  • distance_only (bool) –

    Whether to display distance only.

    distance_only

    past time

    future time

    False

    30 minutes ago

    in 10 seconds

    True

    30 minutes

    10 seconds

  • simple (bool) –

    Whether to return simple human delta, or complex one.

    distance_only

    simple

    time

    False

    False

    1 hour, 1 minute and 1 second ago

    False

    True

    1 hour ago

    True

    False

    1 hour, 1 minute and 1 second

    True

    True

    1 hour

Returns

Human time delta, like 13 hours ago or 42 seconds.

Return type

str

Time

class gd.datetime.time[source]

TimeDelta

class gd.datetime.timedelta[source]
classmethod from_human(string: str, simple: bool = True)TD[source]
to_human(distance_only: bool = False, simple: bool = True)str[source]