Home > TimePeriod

TimePeriod

TimePeriod is a project mainly written in Python, based on the LGPL-2.1 license.

Rewrite of Perl's Time::Period module for Python

TimePeriod - Python module for determining if a datetime is within a time period. This is a Python version of Perl's Time::Period module.

Author: Paul Boyd [email protected]

Installation

To install from an archive:

$ tar zxf TimePeriod-X.Y.tar.gz $ cd TimePeriod-X.Y $ sudo ./setup.py install

Usage

You can use this module like this:

from TimePeriod import inPeriod inPeriod ("wd {th}") 1

If you want to use a time other than the current time, pass a date time after the period:

m datetime import datetime

from TimePeriod import inPeriod inPeriod ("wd {th}", datetime (2007, 1, 1)) 0

Now we know with certainty that New Year's day 2007 was not on Thursday.

The TimePeriod module uses the same format as Perl's Time::Period module, which is detailed here:

http://search.cpan.org/~pryan/Period-1.20/Period.pm

Differences from Time::Period

There are a few intended differences from Time::Period:

1) An exception will be raised for an invalid format. Time::Period returns -1. 2) TimePeriod uses Python's datetime object, instead of an epoch. 3) Years are considered to have a maximum of 366 days, not 365.

License

Released under the LGPL:

http://www.gnu.org/licenses/#LGPL

Also see the LICENSE file.

Previous:demo_app