Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install collective.prettydate

How to install collective.prettydate

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install collective.prettydate
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.2 Available View build log
1.0 Available View build log
1.0rc1 Available View build log
Windows (64-bit)
1.2 Available View build log
1.0 Available View build log
1.0rc1 Available View build log
Mac OS X (10.5+)
1.2 Available View build log
1.1 Available View build log
1.0 Available View build log
1.0rc1 Available View build log
Linux (32-bit)
1.2 Available View build log
1.1 Available View build log
1.0 Available View build log
1.0rc1 Available View build log
Linux (64-bit)
1.2 Available View build log
1.1 Available View build log
1.0 Available View build log
1.0rc1 Available View build log
 
License
GPLv2
Lastest release
version 1.2 on Mar 21st, 2013

Life, the Universe, and Everything

collective.prettydate is a package that helps developers to solve some usability issues associated with the utilization of absolute date formating on sites used among different timezones.

When a date is printed as "01/02/2012" it could represent "February 1" or "January 2", depending on the format used. Also, if the site is located on a different timezone, it could take you to situations when today's date is printed as yesterday, or tomorrow's date.

collective.prettydate represents a date on a relative format so it would be displayed as "4 hours ago", "yesterday" or "last week", which is easier to read and understand for most people.

This feature is really nice for news sites or sites with upcoming events.

Don't Panic

This product provides a utility which will convert a DateTime object into a human readable text.

from zope.component import getUtility
from collective.prettydate.interfaces import IPrettyDate
date_utility = getUtility(IPrettyDate)

At this point, you can use the 'date' method to convert the DateTime object:

from DateTime import DateTime
today = DateTime()
str_date = date_utility.date(today)

In previous example, 'str_date' will be "now"

The 'date' method also allows 2 additional parameters: 'short' and 'asdays' which will modify the output to be in short format ('h' instead of 'hours', 'd' instead of 'days', etc) and whole days (it will use 'today' instead of any amount of seconds, minutes or hours for current day). They both default to "False".

Timezones

If your server timezone is configured correctly, and the DateTime object contains valid timezone info, then the text output will reflect the correct time. You do not need to convert date and time between different timezones.

Output examples
  • '4 hours ago'
  • '4h ago' (short format)
  • 'in 28 minutes'
  • 'in 6 months'
  • 'today'
  • 'last week'
  • 'yesterday'
  • 'last year'
DateTime 3.0

collective.prettydate is fully compatible with DateTime 3.0 which provides a significantly smaller memory footprint.

Mostly Harmless

https://secure.travis-ci.org/collective/collective.prettydate.png

Have an idea? Found a bug? Let us know by opening a support ticket.

Installation

To enable this product in a buildout-based installation:

  1. Edit your buildout.cfg and add collective.prettydate to the list of eggs to install

    [buildout]
    ...
    eggs =
        collective.prettydate
    

After updating the configuration you need to run ''bin/buildout'', which will take care of updating your system.

Share and Enjoy

collective.prettydate would not have been possible without the contribution of the following people:

  • Franco Pellegrini
  • Héctor Velarde
  • Juan A. Díaz

You can find an updated list of package contributors on GitHub.

This package is based on py-pretty.

Development sponsored by Open Multimedia.

Changelog

Because you have to know where your towel is.

1.2 (2013-03-19)
  • Added Finnish translation. [petri]
  • Added Italian translation. [gborelli]
  • Tested compatibility with Plone 4.3. [hvelarde]
  • Updated documentation. [hvelarde]
  • Tested compatibility with Plone 4.0. [hvelarde]
1.1 (2012-05-29)
  • Removed unused test module. [hvelarde]
  • Remove unnecessary generic setup profile. [nueces]
  • Package no longer depends on five.grok (fixes #3). [frapell]
1.0 (2012-05-04)
  • Tested compatibility with Plone 4.2. [hvelarde]
  • Tested compatibility with DateTime 3.0 which provides a significantly smaller memory footprint. [hvelarde]
1.0rc1 (2012-02-21)
  • Initial release.

Subscribe to package updates

Last updated Mar 21st, 2013

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.