dk.ttcal

Date classes (originally from TikTok).

class dk.ttcal.CompareMixin[source]

Mixin class that defines comparison operators, by comparing the (year, month, day) tuple returned by datetuple(). This makes Year() <= Month() <= Week() <= Today().

timetuple()[source]

Create timetuple from datetuple. (to interact with datetime objects).

class dk.ttcal.Day[source]

A calendar date.

Month[source]

Return a Month object representing the month self belongs to.

Year[source]

Return a Year object representing the year self belongs to.

code[source]

One letter code representing the dayname.

compare(other)[source]

Return how similar self is to other.

date()[source]

Excplicitly convert to datetime.date.

datetime(hour=0, minute=0, second=0)[source]

Extend self to datetime.

datetuple()[source]

Return year, month, day.

day_code = ['M', 'U', 'W', 'H', 'F', 'A', 'S']
day_name = [u'mandag', u'tirsdag', u'onsdag', u'torsdag', u'fredag', u'l\xf8rdag', u's\xf8ndag']
dayname[source]

The semi-localized name of self.

display[source]

Return the ‘class’ of self.

first[source]

Define self == self.first for polymorphic usage with other classes.

format(fmt=None)[source]

Emulate Django’s date filter.

classmethod from_idtag(tag)[source]

Return Day from idtag.

static get_day_name(daynum, length=None)[source]

Return dayname for daynum.

idtag[source]

Return the idtag for self: dyyyymmddmm.

in_month[source]

True iff the day is in its month.

isoyear[source]

Return the isoyear of self.

last[source]

Define self == self.last for polymorphic usage with other classes.

next()[source]
classmethod parse(strval)[source]

Parse date value from a string. Allowed syntax include:

yyyy-mm-dd, yyyy-m-dd, yyyy-mm-d, yyyy-m-d dd-mm-yyyy, etc. dd/mm/yyyy, ... dd.mm.yyyy, ... ddmmyyyy

prev()[source]
special[source]

True if the database has an entry for this date (sets special_hours).

today[source]

True if self is today.

week[source]

Return a Week object representing the week self belongs to.

weekday[source]

True if self is a weekday.

weekend[source]

True if self is Saturday or Sunday.

weeknum[source]

Return the isoweek of self.

class dk.ttcal.Days(start, end, start_week=False)[source]

A contigous set of days.

first[source]

1st day

last[source]

last day

class dk.ttcal.Duration[source]

A duration of time.

duration_tuple()[source]

Return self as hours, minutes, seconds.

classmethod parse(txt)[source]

Parse a textual representation into a Duration object. Format HHH:MM:SS.

classmethod sum(sequence, start=None)[source]

Return the sum of sequence. (built-in sum only works with numbers).

toint()[source]

Convert self to integer.

class dk.ttcal.Month(year=None, month=None, date=None)[source]

A calendar month.

Month[source]
Year[source]

Return a Year object for the year-part of this month.

datetuple()[source]

First date in month.

daycount[source]

The number of days in this month (as an int).

dayiter()[source]
days()[source]

Return a list of days (class:ttcal.Day) in this month.

first[source]

First day in month.

format(fmt=None)[source]

Format according to format string. Default format is monthname, four-digit-year.

classmethod from_date(d)[source]

Create a Month from the date d.

classmethod from_idtag(tag)[source]

Parse idtag into class:Month.

idtag()[source]

Return a text representation that is parsable by the from_idtag function (above), and is useable as part of an url.

last[source]

Last day in month.

mark(d, value='mark', method='replace')[source]
marked_days()[source]
month_name = ['', 'Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember']
next()[source]

Next month.

numdays()[source]

The number of days in the month.

classmethod parse(txt)[source]

Parse a textual representation into a Month object. Format YYYY-MM?

prev()[source]

Previous month.

class dk.ttcal.RangeMixin[source]

Requires other class to define .first and .last attributes.

between_tuple(period)[source]

Return a tuple of datetimes that is convenient for sql between queries.

middle[source]

Return the day that splits the date range in half.

range()[source]

Return an iterator for the range of self.

class dk.ttcal.Today[source]

Special subclass for today’s date.

today = True
class dk.ttcal.Week(days, month)[source]
current[source]

True if today is in week.

datetuple()[source]

First day of this week.

first[source]

1st day of week.

classmethod from_idtag(tag)[source]
idtag()[source]
last[source]

Last day of week.

until_today()[source]
classmethod weeknum(n, year=None)[source]
class dk.ttcal.Weeks(start, end)[source]
datetuple()[source]

First day of first week.

dayiter()[source]

Iterate over all days in all the weeks.

first[source]

First day in first week.

last[source]

Last day in last week.

class dk.ttcal.Year(year=None)[source]
H1[source]

First half of this year.

H2[source]

Last half of this year.

Month[source]

For orthogonality in the api.

Q1[source]

1st quarter.

Q2[source]

2nd quarter.

Q3[source]

3rd quarter.

Q4[source]

4th quarter.

Year[source]
april[source]
august[source]
datetuple()[source]

January 1.

dayiter()[source]
december[source]
february[source]
first[source]

First day of first month.

format(fmt=None)[source]

Format according to format string. Default format is monthname, four-digit-year.

classmethod from_idtag(tag)[source]

Year tags have the lower-case letter y + the four digit year, eg. y2008.

halves()[source]

Both halves of the year.

idtag()[source]

Year tags have the lower-case letter y + the four digit year, eg. y2008.

january[source]
july[source]
june[source]
last[source]

Last day of last month.

march[source]
mark(d, value='mark')[source]
mark_period(p, value='mark')[source]
marked_days()[source]
may[source]
next()[source]

Next year.

november[source]
october[source]
prev()[source]

Previous year.

quarters()[source]

Every quarter in this year.

rows()[source]
rows4()[source]
september[source]
dk.ttcal.chop(it, n)[source]

Chop iterator into n size chuchks.

dk.ttcal.from_idtag(idtag)[source]

Return a class from idtag.

dk.ttcal.isoweek(year, week)[source]

Iterate over the days in isoweek week of year.

Previous topic

Project information

Next topic

dk.fstr

This Page