Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
lino.mixins.periods¶
Defines classes related to date ranges.
Functions
|
|
|
|
|
Return a textual representation of the given date range. |
Classes
|
Mixin for models having at least one couple of date and time fields that form a kind of editable timestamp field. |
|
A model mixin that adds two fields start_date and end_date. |
|
|
|
Mixin for models with two fields |
|
An |
|
|
|
Adds two fields |
|
A |
|
An |
|
An |
- lino.mixins.periods.rangetext(self, fmt=<function fdl>, empty_text='')¶
Return a textual representation of the given date range.
The date range is to be specified as an object that has two attributes start_date and end_date.
See tested examples in aids : Aid grantings. Also used by
lino_xl.lib.vat.
- class lino.mixins.periods.CombinedDateTime(*args, **kwargs)¶
Bases:
ModelMixin for models having at least one couple of date and time fields that 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:
CombinedDateTimeAdds two fields
start_dateandstart_time.- start_date¶
- start_time¶
- save(*args, **kw)¶
Fills default value “today” to start_date
- class lino.mixins.periods.Ended(*args, **kwargs)¶
Bases:
CombinedDateTimeMixin for models with two fields
end_dateandend_time.- end_date¶
- end_time¶
- get_duration()¶
Return the duration in hours.
- class lino.mixins.periods.DateRange(*args, **kwargs)¶
Bases:
DateRangeObservableA model mixin that adds two fields start_date and end_date.
DateRangeObservableDesigned for usage with
lino.modlib.system.PeriodEvents.
- class lino.mixins.periods.ObservedDateRange(verbose_name_start='Date from', verbose_name_end='until', **kwargs)¶
Bases:
ParameterPanellino.core.param_panel.ParameterPanelwith two fields start_date and end_date.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:
ObservedDateRangeAn
ObservedDateRangefor 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:
ObservedDateRangeAn
ObservedDateRangewhich defaults to the current month.
- class lino.mixins.periods.Weekly(verbose_name_start='Date from', verbose_name_end='until', **kwargs)¶
Bases:
ObservedDateRangeAn
ObservedDateRangewhich defaults to the current week.
- class lino.mixins.periods.Today(verbose_name='Situation on', **kw)¶
Bases:
ParameterPanelA
ParameterPanelwith a field today that defaults to today.