def day(request, year, month, day, queryset=None, recent_first=False,
    template_name="jellyroll/calendar/day.html", template_loader=loader,
    extra_context=None, context_processors=None, mimetype=None):
    """
    Jellyroll'd items for a particular day.

    Works a bit like a generic view in that you can pass a bunch of optional
    keyword arguments which work just like they do in generic views. Those
    arguments are: ``template_name``, ``template_loader``, ``extra_context``,
    ``context_processors``, and ``mimetype``.
    
    Also takes a ``recent_first`` param; if it's ``True`` the newest items
    will be displayed first; otherwise items will be ordered earliest first.

    You can also pass a ``queryset`` argument; see the module's docstring
    for information about how that works.

    Templates: ``jellyroll/calendar/day.html`` (default)
    Context:
        ``items``
            Items from the month, ordered according to ``recent_first``.
        ``day``
            The day (a ``datetime.date`` object).
        ``previous``
            The previous day; ``None`` if that day was before jellyrolling
            started.
        ``previous_link``
            Link to the previous day
        ``next``
            The next day; ``None`` if it's in the future.
        ``next_link``
            Link to the next day.
        ``is_today``
            ``True`` if this day is today.
    """
    # Make sure we've requested a valid month
    try:
        day = datetime.date(*time.strptime(year+month+day, '%Y%b%d')[:3])
    except ValueError:
        raise Http404("Invalid day string")
    try:
        first = Item.objects.order_by("timestamp")[0]
    except __HOLE__:
        raise Http404("No items; no views.")
    
    today = datetime.date.today()
    if day < first.timestamp.date() or day > today:
        raise Http404("Invalid day (%s .. %s)" % (first.timestamp.date(), today))
    
    # Calculate the previous day
    previous = day - datetime.timedelta(days=1)
    previous_link = urlresolvers.reverse("jellyroll.views.calendar.day", args=previous.strftime("%Y %b %d").lower().split())
    if previous < first.timestamp.date():
        previous = previous_link = None
    
    # And the next month
    next = day + datetime.timedelta(days=1)
    next_link = urlresolvers.reverse("jellyroll.views.calendar.day", args=next.strftime("%Y %b %d").lower().split())
    if next > today:
        next = next_link = None
    
    # Some lookup values...
    timestamp_range = (datetime.datetime.combine(day, datetime.time.min), 
                       datetime.datetime.combine(day, datetime.time.max))
    
    # Handle the initial queryset
    if not queryset:
       queryset = Item.objects.all()
    queryset = queryset.filter(timestamp__range=timestamp_range)
    if not queryset.query.order_by:
        if recent_first:
            queryset = queryset.order_by("-timestamp")
        else:
            queryset = queryset.order_by("timestamp")
    
    # Build the context
    context = RequestContext(request, {
        "items"         : queryset,
        "day"           : day,
        "previous"      : previous,
        "previous_link" : previous_link,
        "next"          : next,
        "next_link"     : next_link,
        "is_today"      : day == today,
    }, context_processors)
    if extra_context:
        for key, value in extra_context.items():
            if callable(value):
                context[key] = value()
            else:
                context[key] = value
    
    # Load, render, and return
    t = template_loader.get_template(template_name)
    return HttpResponse(t.render(context), mimetype=mimetype)
dataset/ETHPy150Open jacobian-archive/jellyroll/src/jellyroll/views/calendar.py/day