Skip to content

Latest commit

 

History

History
138 lines (85 loc) · 3.09 KB

datetime.rst

File metadata and controls

138 lines (85 loc) · 3.09 KB

xotl.tools.future.datetime - Basic date and time types

xotl.tools.future.datetime

This module extends the standard library's datetime. You may use it as a drop-in replacement in many cases.

Avoid importing * from this module since could be different in Python 2.7 and Python 3.3.

In Pytnon versions <= 3 date format fails for several dates, for example date(1800, 1, 1).strftime("%Y"). So, classes ~datetime.date and ~datetime.datetime are redefined if that case.

This problem could be solved by redefining the strftime function in the time module, because it is used for all strftime methods; but (WTF), Python double checks the year (in each method and then again in time.strftime function).

assure

We added the following features.

strfdelta

strftime

get_month_first

get_month_last

get_next_month

is_full_month

flextime

daterange([start,] stop[, step])

DateField

TimeSpan

from_date

past_unbound

future_unbound

unbound

bound

valid

__le__

issubset

An alias for __le__.

__ge__

issuperset

An alias for __ge__.

covers

An alias for __ge__.

isdisjoint

overlaps

__contains__

__and__

__mul__

An alias for __and__.

intersection

__lshift__

__rshift__

__len__

diff

DateTimeSpan

from_datetime

from_timespan

past_unbound

future_unbound

unbound

bound

valid

__le__

issubset

An alias for __le__.

__ge__

issuperset

An alias for __ge__.

covers

An alias for __ge__.

isdisjoint

overlaps

__contains__

__and__

__mul__

An alias for __and__.

intersection

__lshift__

__rshift__

__len__

diff

EmptyTimeSpan

The empty time span. It's not an instance of TimeSpan but engage set-like operations: union, intersection, etc.

No date is a member of the empty time span. The empty time span is a proper subset of any time span. It's only a superset of itself. It's not a proper superset of any other time span nor itself.

This instance is a singleton.