コード例 #1
0
def timeslot_offset_options(interval=temporale_settings.TIMESLOT_INTERVAL,
    start_time=temporale_settings.TIMESLOT_START_TIME,
    end_delta=temporale_settings.TIMESLOT_END_TIME_DURATION,
    fmt=temporale_settings.TIMESLOT_TIME_FORMAT):
    """
    Create a list of time slot options for use in temporale forms.

    The list is comprised of 2-tuples containing the number of seconds since the
    start of the day and a 12-hour temporal representation of that offset.
    """
    dt = datetime.combine(date.today(), time(0))
    dtstart = datetime.combine(dt.date(), start_time)
    dtend = dtstart + end_delta
    options = []

    delta = utils.time_delta_total_seconds(dtstart - dt)
    seconds = utils.time_delta_total_seconds(interval)
    while dtstart <= dtend:
        options.append((delta, dtstart.strftime(fmt)))
        dtstart += interval
        delta += seconds

    return options
コード例 #2
0
    ('until', _('Until date')),
)

ISO_WEEKDAYS_MAP = (
    None,
    rrule.MO,
    rrule.TU,
    rrule.WE,
    rrule.TH,
    rrule.FR,
    rrule.SA,
    rrule.SU
)

MINUTES_INTERVAL = temporale_settings.TIMESLOT_INTERVAL.seconds // 60
SECONDS_INTERVAL = utils.time_delta_total_seconds(temporale_settings.DEFAULT_OCCURRENCE_DURATION)


def timeslot_options(interval=temporale_settings.TIMESLOT_INTERVAL,
    start_time=temporale_settings.TIMESLOT_START_TIME,
    end_delta=temporale_settings.TIMESLOT_END_TIME_DURATION,
    fmt=temporale_settings.TIMESLOT_TIME_FORMAT):
    """
    Create a list of time slot options for use in temporale forms.

    The list is comprised of 2-tuples containing a 24-hour time value and a
    12-hour temporal representation of that offset.
    """
    dt = datetime.combine(date.today(), time(0))
    dtstart = datetime.combine(dt.date(), start_time)
    dtend = dtstart + end_delta