Login

Tag "date"

Snippet List

DateTimeWidget using JSCal2

DateTimeWidget using [JSCal2](http://www.dynarch.com/projects/calendar/) Duplicate of [this snippet](http://www.djangosnippets.org/snippets/391/), but for latest 1.5 version of DHTML Calendar. Also here is **fixed problem of previous widget** linked to *form.changed_data* and *EntryLog.message*. This is fixed by adding own, little modified *_has_changed()* method

  • datetime
  • date
  • calendar
  • widget
  • dhtml
Read More

Template-Filter for Feedparser-Dates

A filter that changes a preparsed date from [Ultimate Feedparser](http://www.feedparser.org/) to a regular datetime instance. Now you can -for example- pass a feed parsed by feedparser to a template and do this: {% for item in feed.entries %} Title: {{ item.title }}<br /> Date: {{ item.updated_parsed|feedparsed|date:"Y-m-d" }} {% endfor %}

  • template-filter
  • datetime
  • date
  • feedparser
Read More

Python Calendar wrapper template tag

This tag gives you an iterable Python [Calendar object](http://docs.python.org/library/calendar.html) in your template namespace. It is used in the [django-calendar](http://github.com/dokterbob/django-agenda) project. Use it as follows in your template: {% get_calendar for <month_number_or_variable> <year_or_variable> as calendar %} <table> <tr> <th>Mon</th> <th>Tue</th> <th>Wed</th> <th>Thu</th> <th>Fri</th> <th>Sat</th> <th>Sun</th> </tr> {% for week in calendar %} <tr> {% for day in week %} <td>{{ day.day }}</td> {% endfor %} </tr> {% endfor %} </table>

  • template
  • tag
  • date
  • calendar
Read More

Time toggle on mouseover template filter

Shows the timesince to the user and then on mouseover it will display the exact time for allowing the user to see the exact time. Example: shows "about 1 day, 3 hours ago" and then changes on mouseover to read "at 3:05pm on Wednesday 22nd April 2009"

  • date
  • time
  • usability
  • time-toggle
Read More

HTML/JS template filter to show localized dates/times

While working on my website projects today I had the idea to use HTML/JS instead of a IP database to localize the dates and times shown on the websites. Here are the snippets to use the JS snippets as filters for Django running on Google App Engine. You can use those filters on datetime objects.

  • template
  • filter
  • django
  • datetime
  • date
  • time
  • appengine
  • local
Read More

Smart i18n date diff (twitter like)

This snippet display a human readable date diff. You give it the your date in parameter and the diff with datetime.datetime.now() is returned. The diff must be positive to be more accurate (future dates are not supported) Usage: {{ status.created_at|date_diff }} Will give something like: less than 1 minute ago 13 minutes ago 1 hour ago etc. Based on [Fuzzy Date Diff Template Filter](http://www.djangosnippets.org/snippets/1347/)

  • datetime
  • i18n
  • date
  • diff
Read More

copyright_since

**Example usage**: {% copyright_since 2008 %}, {% copyright_since 2009 %} **Output**: © 2008—2009, © 2009 Use this templatetag in your footer to achieve proper formatting of copyright notice.

  • datetime
  • date
  • template-tag
  • formatting
  • copyright
  • copyright-formatting
  • copyright-year
Read More

Fuzzy Date Diff Template Filter

Pass in a date and you get a humanized fuzzy date diff; e.g. "2 weeks ago" or "in 5 months". The date you pass in can be in the past or future (or even the present, for that matter). The result is rounded, so a date 45 days ago will be "2 months ago", and a date 400 days from now will be "in 1 year". Usage: * `{{ my_date|date_diff }}` will give you a date_diff between `my_date` and `datetime.date.today()` * `{{ my_date|date_diff:another_date }}` will give you a date_diff between `my_date` and `another_date` Make sure to install this as a template tag and call `{% load date_diff %}` in your template; see the [custom template tag docs](http://docs.djangoproject.com/en/dev/howto/custom-template-tags/) if you don't know how to do that.

  • template
  • filter
  • date
  • humanize
Read More

Date Picker Template Include

All you need to do is include the file you save this as in your other templates. The css and javascript is right in the file. Fully customizable. Very easy. Click a date to choose a single date. Click a second date to choose a range. A third click will act as a first click. note: you also will want to customize the django template specific variables in elements with ids: s_date e_date cal_month if you change those, it's not even really django specific, but i use this in my form for time off requests at work.

  • template
  • date
  • picker
  • include
Read More

Get stories by category and some date range

Removed for now... Not sure where to share new Ellington snippets due to the gray-area of it being proprietary. It's an awesome package but it's hard to find any good help with Django 91 code. Good luck ellingtoners!

  • date
  • stories
  • category
Read More

TodayDateTimeField

Automatically sets date to today if only time part was entered. If today is 01/01/2008, then both DateTimeField and TodayDateTimeField clean '2008-01-01 15:05' to datetime(2008,01,01,15,5,0), while '15:05' is cleaned as datetime(1900,01,01,15,5,0) for DateTimeField but datetime(2008,01,01,15,5,0) for TodayDateTimeField.

  • date
  • time
  • field
  • today
Read More

Date/time util template filters

**Explanations:** - the series "is_*_of" was created 'cos it's easier write: `{% if 10|is_day_of:date and user %}` than write: `{% ifequal date.day 10 %}{% if user %}...` - the series "inc/dec" is not complete, but can the extended to day, hour, minute, etc as you needs. It's util to inc 10 months since 05/31/2006 by example and get a 2007's date :) **Setup:** Insert the snippet into an_app/templatetags/datetimeutils.py. **Use in template:** `{% load datetimeutils %}` and use filters as following: - `{{ 30|is_day_of:a_date_time_variable }}` - `{{ 11|is_month_of:a_date_time_variable }}` - `{{ 2006|is_year_of:a_date_time_variable }}` - `{{ 58|is_minute_of:a_date_time_variable }}` - `{{ 23|is_hour_of:a_date_time_variable }}` - `{{ a_date_time_variable|dec_year:2 }}` - `{{ a_date_time_variable|dec_month:2 }}` - `{{ a_date_time_variable|inc_year:2 }}` - `{{ a_date_time_variable|inc_month:2 }}`

  • date
  • time
  • template-filters
Read More

37 snippets posted so far.