Git Product home page Git Product logo

django-dana-time's Introduction

Django Dana Time Build Status

Short, readable datetime filters.

Install

$ pip install django-dana-time

Usage

{% load danatime %}

{{ datetime_instance|danatime:"previous year format" }}

Formatting

Examples are shown with en translation/formatting and no arguments to the template tag.

timedelta danatime
0 seconds now
1 second a second ago
2 - 60 seconds 2 - 60 seconds ago
1 minute a minute ago
2 - 60 minutes 2 - 60 minutes ago
1 hour an hour ago
2 - 6 hours 2 - 6 hours ago
6 - 24 hours, same day 4:26 p.m.
6 - 24 hours, yesterday 4:26 p.m. yesterday
> 24 hours, same year Aug 10
previous year 8/10/2012

Internationalization Notes

All values are internationalized and localized by default using Django's internationalization and localization support.

6 - 24 hours (same day/yesterday)

Uses defaultfilters.time, which defaults to the localized settings.TIME_FORMAT.

Example: In en, TIME_FORMAT = 'P'.

> 24 hours, same year

Uses defaultfilters.date with an argument of 'MONTH_DAY_FORMAT', the localized settings.MONTH_DAY_FORMAT.

Example: In en, MONTH_DAY_FORMAT = 'F j'.

previous year

Uses defaultfilters.date with an argument of 'n/j/Y'.

Example: 10 August 2012 is formatted as 8/10/2012.

Override this by passing an optional argument with a format to the filter tag.

previous year format examples:

Pass None to use the default, localized settings.DATE_FORMAT:

{{ mytime|danatime:None }}

Pass SHORT_DATE_FORMAT to use the localized settings.SHORT_DATE_FORMAT:

{{ mytime|danatime:"SHORT_DATE_FORMAT" }}

Pass a format string like "F j, Y" to use a custom format:

{{ mytime|danatime:"F j, Y" }}

This particular format yields August 8, 2012.

See Django's available format strings for help.

Testing

Build Status

Tested with all combinations of the latest versions of Python 2.7 and 3.4 with Django 1.7, 1.8, and 1.9.

After installing Django, run the tests with:

$ python runtests.py

Install tox and run tox to test in all environments. This is what the CI does.

django-dana-time's People

Contributors

danasilver avatar teddyknox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

django-dana-time's Issues

Future dates

Maybe some scheme like this:

timedelta danatime
0 seconds now
1 second in a second
2 - 60 seconds in 2 - 60 seconds
1 minute in a minute
2 - 60 minutes in 2 - 60 minutes
1 hour, same day in an hour
2 - 6 hours, same day in 2 - 6 hours
6 - 24 hours, same day at 4:26 pm (12 hour)
> 24 hours, same year on Aug 10
next year on 8/10/12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.