lino.mixins.periods

Defines classes related to date ranges.

(This module's source code is available here.)

Functions

rangefmt(r)

Classes

CombinedDateTime(*args, **kwargs)

Mixin for models which have at least one couple of date and time fields which form a kind of editable timestamp field.

DateRange(*args, **kwargs)

Mixin for models which represent a period whose start and end are date fields.

DateRangeObservable(*args, **kwargs)

Ended(*args, **kwargs)

Mixin for models with two fields end_date and end_time.

Monthly([verbose_name_start, verbose_name_end])

An ObservedDateRange which defaults to the current month.

ObservedDateRange([verbose_name_start, ...])

lino.core.param_panel.ParameterPanel with two fields start_date and end_date which default to empty.

Started(*args, **kwargs)

Adds two fields start_date and start_time.

Today([verbose_name])

A ParameterPanel with a field today which defaults to today.

Yearly([verbose_name_start, verbose_name_end])

An ObservedDateRange for which start_date defaults to Jan 1st and end_date to Dec 31 of the current year.

class lino.mixins.periods.CombinedDateTime(*args, **kwargs)

Bases: lino.core.model.Model

Mixin for models which have at least one couple of date and time fields which form a kind of editable timestamp field.

get_time_zone()

The time zone for the date and time fields in this model.

Expected to always return an instance of lino.modlib.about.choicelists.TimeZone.

May get overridden to return the author's timezone.

set_datetime(name, value)

Given a datetime value, update the two corresponding fields FOO_date and FOO_time (where FOO is specified in name which must be either "start" or "end").

get_datetime(name, altname=None)

Return a datetime value from the two corresponding date and time fields.

name can be 'start' or 'end'.

The optional altname can be used e.g. in a single-day calendar event to support having end_date empty, meaning "same as start_date". In that case you should ask get_datetime("end", "start").

class lino.mixins.periods.Started(*args, **kwargs)

Bases: lino.mixins.periods.CombinedDateTime

Adds two fields start_date and start_time.

start_date
start_time
save(*args, **kw)

Fills default value "today" to start_date

class lino.mixins.periods.Ended(*args, **kwargs)

Bases: lino.mixins.periods.CombinedDateTime

Mixin for models with two fields end_date and end_time.

end_date
end_time
get_duration()

Return the duration in hours.

class lino.mixins.periods.DateRange(*args, **kwargs)

Bases: lino.mixins.periods.DateRangeObservable

Mixin for models which represent a period whose start and end are date fields.

Designed for usage with lino.modlib.system.choicelists.PeriodEvents.

class lino.mixins.periods.ObservedDateRange(verbose_name_start='Date from', verbose_name_end='until', **kwargs)

Bases: lino.core.utils.ParameterPanel

lino.core.param_panel.ParameterPanel with two fields start_date and end_date which default to empty.

Note that you must define yourself a get_request_queryset method in order to actually use these two parameter fields.

class lino.mixins.periods.Yearly(verbose_name_start='Date from', verbose_name_end='until', **kwargs)

Bases: lino.mixins.periods.ObservedDateRange

An ObservedDateRange for which start_date defaults to Jan 1st and end_date to Dec 31 of the current year.

class lino.mixins.periods.Monthly(verbose_name_start='Date from', verbose_name_end='until', **kwargs)

Bases: lino.mixins.periods.ObservedDateRange

An ObservedDateRange which defaults to the current month.

class lino.mixins.periods.Today(verbose_name='Situation on', **kw)

Bases: lino.core.utils.ParameterPanel

A ParameterPanel with a field today which defaults to today.