This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Sane date and time tools for Python.

[![Build Status](https://travis-ci.org/WiFast/era.svg?branch=master)](https://travis-ci.org/WiFast/era)

What Is It?

Era is a collection of tools for managing dates/times with associated timezone information. Some fine points:

  • Era assumes UTC for all timezones when not specified.
  • Naive datetimes (those without timezones) are treated as being in the local timezone.
  • You should be using UTC for all the things. See [Problems with Localtime][2].
  • Documentation is inline in era.py.

What’s In It?

Imports so that you don’t have to import fifteen different modules.

  • calendar
  • tzlocal
  • timezone - from pytz
  • utc - from pytz
  • date
  • datetime
  • time
  • timedelta
  • tzinfo

Useful constants:

  • utc - The UTC timezone.
  • localtz - The local timezone.
  • epoch - The Unix Epoch. 1 January 1970 in UTC.

Day of week constants.

  • mon = 0
  • tue = 1
  • wed = 2
  • thu = 3
  • fri = 4
  • sat = 5
  • sun = 6

Time units. Each unit is a number of (or fraction of) seconds. These are naive in that they do not account for differences in months (a month is 30 days here), leap years (a year is 365 days), leap seconds, or any other real life scenario that would make the measurement incorrect.

  • second = 1
  • millisecond = second / 1000.0
  • microsecond = millisecond / 1000.0
  • minute = 60 * second
  • hour = 60 * minute
  • day = 24 * hour
  • week = 7 * day
  • month = 30 * day
  • year = 365 * day

Defined functions:

  • is_time - Check if a value is a time.
  • is_date - Check if a value is a date.
  • is_datetime - Check if a value is a datetime.
  • to_datetime - Convert a value to a datetime.
  • settz - Set a timezone without accounting for a time change.
  • totz - Convert a time from one timezone to another.
  • localize - Convert a time to the local timezone.
  • now - Get the current time in a particular timezone.
  • localnow - Get the current time in the local timezone.
  • daysago - Get a date from n days ago.
  • timeago - Get a time from n time ago.
  • ts - Get the Unix timestamp for a value (seconds since the epoch).
  • tsms - Get the Javascript timestamp for a value (milliseconds since the epoch).
  • fromts - Get a time from a Unix timestamp.
  • fromtsms - Get a time from a Javascript timestamp.
  • truncate - Reduce the precision of a date/time.
  • weekday - Find the date for the given day of the week.
  • prevweekday - Find the date for the most recent day of the week.
  • nextweekday - Find the date for the next week day.

License

Copyright (c) 2014 WiFast, Inc. This project and all of its contents is licensed under the BSD-derived license as found in the included [LICENSE][1] file.

[1]: https://github.com/WiFast/era/blob/master/LICENSE “LICENSE” [2]: http://pytz.sourceforge.net/#problems-with-localtime “Problems with Localtime”

Release History

Release History

1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
era-1.1.tar.gz (4.4 kB) Copy SHA256 Checksum SHA256 Source Jun 18, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting