pax_global_header 0000666 0000000 0000000 00000000064 12605232351 0014511 g ustar 00root root 0000000 0000000 52 comment=2fdf51b4cc7c43a1913347ef851d8bf94aa110b6
arrow-0.7.0/ 0000775 0000000 0000000 00000000000 12605232351 0012647 5 ustar 00root root 0000000 0000000 arrow-0.7.0/.coveragerc 0000664 0000000 0000000 00000000037 12605232351 0014770 0 ustar 00root root 0000000 0000000 [run]
include =
arrow/*.py
arrow-0.7.0/.gitignore 0000664 0000000 0000000 00000000125 12605232351 0014635 0 ustar 00root root 0000000 0000000 *.pyc
*.egg-info
.coverage
nosetests.xml
local/
dist/
docs/_build/
.idea
.DS_Store
arrow-0.7.0/.travis.yml 0000664 0000000 0000000 00000000554 12605232351 0014764 0 ustar 00root root 0000000 0000000 language: python
python:
- 2.6
- 2.7
- 3.3
- 3.4
install:
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then make build26; fi
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then make build27; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then make build33; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.4' ]]; then make build34; fi
script: make test
arrow-0.7.0/HISTORY.md 0000664 0000000 0000000 00000017155 12605232351 0014343 0 ustar 00root root 0000000 0000000 ## History
### 0.7.0
- [FIX] Parse localized strings #228 (swistakm)
- [FIX] Modify tzinfo parameter in `get` api #221 (bottleimp)
- [FIX] Fix Czech locale (PrehistoricTeam)
- [FIX] Raise TypeError when adding/subtracting non-dates (itsmeolivia)
- [FIX] Fix pytz conversion error (Kudo)
- [FIX] Fix overzealous time truncation in span_range (kdeldycke)
- [NEW] Humanize for time duration #232 (ybrs)
- [NEW] Add Thai locale (sipp11)
- [NEW] Adding Belarusian (be) locale (oire)
- [NEW] Search date in strings (beenje)
- [NEW] Note that arrow's tokens differ from strptime's. (offby1)
### 0.6.0
- [FIX] Added support for Python 3
- [FIX] Avoid truncating oversized epoch timestamps. Fixes #216.
- [FIX] Fixed month abbreviations for Ukrainian
- [FIX] Fix typo timezone
- [FIX] A couple of dialect fixes and two new languages
- [FIX] Spanish locale: `Miercoles` should have acute accent
- [Fix] Fix Finnish grammar
- [FIX] Fix typo in 'Arrow.floor' docstring
- [FIX] Use read() utility to open README
- [FIX] span_range for week frame
- [NEW] Add minimal support for fractional seconds longer than six digits.
- [NEW] Adding locale support for Marathi (mr)
- [NEW] Add count argument to span method
- [NEW] Improved docs
### 0.5.1 - 0.5.4
- [FIX] test the behavior of simplejson instead of calling for_json directly (tonyseek)
- [FIX] Add Hebrew Locale (doodyparizada)
- [FIX] Update documentation location (andrewelkins)
- [FIX] Update setup.py Development Status level (andrewelkins)
- [FIX] Case insensitive month match (cshowe)
### 0.5.0
- [NEW] struct_time addition. (mhworth)
- [NEW] Version grep (eirnym)
- [NEW] Default to ISO-8601 format (emonty)
- [NEW] Raise TypeError on comparison (sniekamp)
- [NEW] Adding Macedonian(mk) locale (krisfremen)
- [FIX] Fix for ISO seconds and fractional seconds (sdispater) (andrewelkins)
- [FIX] Use correct Dutch wording for "hours" (wbolster)
- [FIX] Complete the list of english locales (indorilftw)
- [FIX] Change README to reStructuredText (nyuszika7h)
- [FIX] Parse lower-cased 'h' (tamentis)
- [FIX] Slight modifications to Dutch locale (nvie)
### 0.4.4
- [NEW] Include the docs in the released tarball
- [NEW] Czech localization Czech localization for Arrow
- [NEW] Add fa_ir to locales
- [FIX] Fixes parsing of time strings with a final Z
- [FIX] Fixes ISO parsing and formatting for fractional seconds
- [FIX] test_fromtimestamp sp
- [FIX] some typos fixed
- [FIX] removed an unused import statement
- [FIX] docs table fix
- [FIX] Issue with specify 'X' template and no template at all to arrow.get
- [FIX] Fix "import" typo in docs/index.rst
- [FIX] Fix unit tests for zero passed
- [FIX] Update layout.html
- [FIX] In Norwegian and new Norwegian months and weekdays should not be capitalized
- [FIX] Fixed discrepancy between specifying 'X' to arrow.get and specifying no template
### 0.4.3
- [NEW] Turkish locale (Emre)
- [NEW] Arabic locale (Mosab Ahmad)
- [NEW] Danish locale (Holmars)
- [NEW] Icelandic locale (Holmars)
- [NEW] Hindi locale (Atmb4u)
- [NEW] Malayalam locale (Atmb4u)
- [NEW] Finnish locale (Stormpat)
- [NEW] Portuguese locale (Danielcorreia)
- [NEW] ``h`` and ``hh`` strings are now supported (Averyonghub)
- [FIX] An incorrect inflection in the Polish locale has been fixed (Avalanchy)
- [FIX] ``arrow.get`` now properly handles ``Date``s (Jaapz)
- [FIX] Tests are now declared in ``setup.py`` and the manifest (Pypingou)
- [FIX] ``__version__`` has been added to ``__init__.py`` (Sametmax)
- [FIX] ISO 8601 strings can be parsed without a separator (Ivandiguisto / Root)
- [FIX] Documentation is now more clear regarding some inputs on ``arrow.get`` (Eriktaubeneck)
- [FIX] Some documentation links have been fixed (Vrutsky)
- [FIX] Error messages for parse errors are now more descriptive (Maciej Albin)
- [FIX] The parser now correctly checks for separators in strings (Mschwager)
### 0.4.2
- [NEW] Factory ``get`` method now accepts a single ``Arrow`` argument.
- [NEW] Tokens SSSS, SSSSS and SSSSSS are supported in parsing.
- [NEW] ``Arrow`` objects have a ``float_timestamp`` property.
- [NEW] Vietnamese locale (Iu1nguoi)
- [NEW] Factory ``get`` method now accepts a list of format strings (Dgilland)
- [NEW] A MANIFEST.in file has been added (Pypingou)
- [NEW] Tests can be run directly from ``setup.py`` (Pypingou)
- [FIX] Arrow docs now list 'day of week' format tokens correctly (Rudolphfroger)
- [FIX] Several issues with the Korean locale have been resolved (Yoloseem)
- [FIX] ``humanize`` now correctly returns unicode (Shvechikov)
- [FIX] ``Arrow`` objects now pickle / unpickle correctly (Yoloseem)
### 0.4.1
- [NEW] Table / explanation of formatting & parsing tokens in docs
- [NEW] Brazilian locale (Augusto2112)
- [NEW] Dutch locale (OrangeTux)
- [NEW] Italian locale (Pertux)
- [NEW] Austrain locale (LeChewbacca)
- [NEW] Tagalog locale (Marksteve)
- [FIX] Corrected spelling and day numbers in German locale (LeChewbacca)
- [FIX] Factory ``get`` method should now handle unicode strings correctly (Bwells)
- [FIX] Midnight and noon should now parse and format correctly (Bwells)
### 0.4.0
- [NEW] Format-free ISO-8601 parsing in factory ``get`` method
- [NEW] Support for 'week' / 'weeks' in ``span``, ``range``, ``span_range``, ``floor`` and ``ceil``
- [NEW] Support for 'weeks' in ``replace``
- [NEW] Norwegian locale (Martinp)
- [NEW] Japanese locale (CortYuming)
- [FIX] Timezones no longer show the wrong sign when formatted (Bean)
- [FIX] Microseconds are parsed correctly from strings (Bsidhom)
- [FIX] Locale day-of-week is no longer off by one (Cynddl)
- [FIX] Corrected plurals of Ukrainian and Russian nouns (Catchagain)
- [CHANGE] Old 0.1 ``arrow`` module method removed
- [CHANGE] Dropped timestamp support in ``range`` and ``span_range`` (never worked correctly)
- [CHANGE] Dropped parsing of single string as tz string in factory ``get`` method (replaced by ISO-8601)
### 0.3.5
- [NEW] French locale (Cynddl)
- [NEW] Spanish locale (Slapresta)
- [FIX] Ranges handle multiple timezones correctly (Ftobia)
### 0.3.4
- [FIX] Humanize no longer sometimes returns the wrong month delta
- [FIX] ``__format__`` works correctly with no format string
### 0.3.3
- [NEW] Python 2.6 support
- [NEW] Initial support for locale-based parsing and formatting
- [NEW] ArrowFactory class, now proxied as the module API
- [NEW] ``factory`` api method to obtain a factory for a custom type
- [FIX] Python 3 support and tests completely ironed out
### 0.3.2
- [NEW] Python 3+ support
### 0.3.1
- [FIX] The old ``arrow`` module function handles timestamps correctly as it used to
### 0.3.0
- [NEW] ``Arrow.replace`` method
- [NEW] Accept timestamps, datetimes and Arrows for datetime inputs, where reasonable
- [FIX] ``range`` and ``span_range`` respect end and limit parameters correctly
- [CHANGE] Arrow objects are no longer mutable
- [CHANGE] Plural attribute name semantics altered: single -> absolute, plural -> relative
- [CHANGE] Plural names no longer supported as properties (e.g. ``arrow.utcnow().years``)
### 0.2.1
- [NEW] Support for localized humanization
- [NEW] English, Russian, Greek, Korean, Chinese locales
### 0.2.0
- **REWRITE**
- [NEW] Date parsing
- [NEW] Date formatting
- [NEW] ``floor``, ``ceil`` and ``span`` methods
- [NEW] ``datetime`` interface implementation
- [NEW] ``clone`` method
- [NEW] ``get``, ``now`` and ``utcnow`` API methods
### 0.1.6
- [NEW] Humanized time deltas
- [NEW] ``__eq__`` implemented
- [FIX] Issues with conversions related to daylight savings time resolved
- [CHANGE] ``__str__`` uses ISO formatting
### 0.1.5
- **Started tracking changes**
- [NEW] Parsing of ISO-formatted time zone offsets (e.g. '+02:30', '-05:00')
- [NEW] Resolved some issues with timestamps and delta / Olson time zones
arrow-0.7.0/LICENSE 0000664 0000000 0000000 00000001103 12605232351 0013647 0 ustar 00root root 0000000 0000000 Copyright 2013 Chris Smith
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
arrow-0.7.0/MANIFEST.in 0000664 0000000 0000000 00000000131 12605232351 0014400 0 ustar 00root root 0000000 0000000 include LICENSE HISTORY.md README.rst
recursive-include tests *
recursive-include docs *
arrow-0.7.0/Makefile 0000664 0000000 0000000 00000001352 12605232351 0014310 0 ustar 00root root 0000000 0000000 .PHONY: auto build test docs clean
auto: build27
build27:
virtualenv local --python=python2.7
local/bin/pip install --use-mirrors -r requirements.txt
build26:
virtualenv local --python=python2.6
local/bin/pip install --use-mirrors -r requirements.txt
local/bin/pip install --use-mirrors -r requirements26.txt
build33:
virtualenv local --python=python3.3
local/bin/pip install --use-mirrors -r requirements.txt
build34:
virtualenv local --python=python3.4
local/bin/pip install --use-mirrors -r requirements.txt
test:
rm -f .coverage
. local/bin/activate && nosetests --all-modules --with-coverage arrow tests
docs:
touch docs/index.rst
cd docs; make html
clean:
rm -rf local
rm -f arrow/*.pyc tests/*.pyc
rm -f .coverage
arrow-0.7.0/README.rst 0000664 0000000 0000000 00000006360 12605232351 0014343 0 ustar 00root root 0000000 0000000 Arrow - Better dates & times for Python
=======================================
.. image:: https://travis-ci.org/crsmithdev/arrow.png
:alt: build status
:target: https://travis-ci.org/crsmithdev/arrow
.. image:: https://pypip.in/d/arrow/badge.png
:alt: downloads
:target: https://crate.io/packages/arrow
Documentation: `arrow.readthedocs.org `_
---------------------------------------------------------------------------------
What?
-----
Arrow is a Python library that offers a sensible, human-friendly approach to creating, manipulating, formatting and converting dates, times, and timestamps. It implements and updates the datetime type, plugging gaps in functionality, and provides an intelligent module API that supports many common creation scenarios. Simply put, it helps you work with dates and times with fewer imports and a lot less code.
Arrow is heavily inspired by `moment.js `_ and `requests `_
Why?
----
Python's standard library and some other low-level modules have near-complete date, time and time zone functionality but don't work very well from a usability perspective:
- Too many modules: datetime, time, calendar, dateutil, pytz and more
- Too many types: date, time, datetime, tzinfo, timedelta, relativedelta, etc.
- Time zones and timestamp conversions are verbose and unpleasant
- Time zone naievety is the norm
- Gaps in functionality: ISO-8601 parsing, timespans, humanization
Features
--------
- Fully implemented, drop-in replacement for datetime
- Supports Python 2.6, 2.7 and 3.3
- Time zone-aware & UTC by default
- Provides super-simple creation options for many common input scenarios
- Updated .replace method with support for relative offsets, including weeks
- Formats and parses strings, including ISO-8601-formatted strings automatically
- Timezone conversion
- Timestamp available as a property
- Generates time spans, ranges, floors and ceilings in timeframes from year to microsecond
- Humanizes and supports a growing list of contributed locales
- Extensible for your own Arrow-derived types
Quick start
-----------
First:
.. code-block:: console
$ pip install arrow
And then:
.. code-block:: pycon
>>> import arrow
>>> utc = arrow.utcnow()
>>> utc
>>> utc = utc.replace(hours=-1)
>>> utc
>>> local = utc.to('US/Pacific')
>>> local
>>> arrow.get('2013-05-11T21:23:58.970460+00:00')
>>> local.timestamp
1368303838
>>> local.format()
'2013-05-11 13:23:58 -07:00'
>>> local.format('YYYY-MM-DD HH:mm:ss ZZ')
'2013-05-11 13:23:58 -07:00'
>>> local.humanize()
'an hour ago'
>>> local.humanize(locale='ko_kr')
'1시간 전'
Further documentation can be found at `arrow.readthedocs.org `_
Contributing
------------
Contributions are welcome, especially with localization. See `locales.py `_ for what's currently supported.
arrow-0.7.0/arrow/ 0000775 0000000 0000000 00000000000 12605232351 0014001 5 ustar 00root root 0000000 0000000 arrow-0.7.0/arrow/__init__.py 0000664 0000000 0000000 00000000243 12605232351 0016111 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
from .arrow import Arrow
from .factory import ArrowFactory
from .api import get, now, utcnow
__version__ = '0.7.0'
VERSION = __version__
arrow-0.7.0/arrow/api.py 0000664 0000000 0000000 00000002114 12605232351 0015122 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
'''
Provides the default implementation of :class:`ArrowFactory `
methods for use as a module API.
'''
from __future__ import absolute_import
from arrow.factory import ArrowFactory
# internal default factory.
_factory = ArrowFactory()
def get(*args, **kwargs):
''' Implements the default :class:`ArrowFactory `
``get`` method.
'''
return _factory.get(*args, **kwargs)
def utcnow():
''' Implements the default :class:`ArrowFactory `
``utcnow`` method.
'''
return _factory.utcnow()
def now(tz=None):
''' Implements the default :class:`ArrowFactory `
``now`` method.
'''
return _factory.now(tz)
def factory(type):
''' Returns an :class:`.ArrowFactory` for the specified :class:`Arrow `
or derived type.
:param type: the type, :class:`Arrow ` or derived.
'''
return ArrowFactory(type)
__all__ = ['get', 'utcnow', 'now', 'factory', 'iso']
arrow-0.7.0/arrow/arrow.py 0000664 0000000 0000000 00000070255 12605232351 0015516 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
'''
Provides the :class:`Arrow ` class, an enhanced ``datetime``
replacement.
'''
from __future__ import absolute_import
from datetime import datetime, timedelta, tzinfo
from dateutil import tz as dateutil_tz
from dateutil.relativedelta import relativedelta
import calendar
import sys
from arrow import util, locales, parser, formatter
class Arrow(object):
'''An :class:`Arrow ` object.
Implements the ``datetime`` interface, behaving as an aware ``datetime`` while implementing
additional functionality.
:param year: the calendar year.
:param month: the calendar month.
:param day: the calendar day.
:param hour: (optional) the hour. Defaults to 0.
:param minute: (optional) the minute, Defaults to 0.
:param second: (optional) the second, Defaults to 0.
:param microsecond: (optional) the microsecond. Defaults 0.
:param tzinfo: (optional) the ``tzinfo`` object. Defaults to ``None``.
If tzinfo is None, it is assumed to be UTC on creation.
Usage::
>>> import arrow
>>> arrow.Arrow(2013, 5, 5, 12, 30, 45)
'''
resolution = datetime.resolution
_ATTRS = ['year', 'month', 'day', 'hour', 'minute', 'second', 'microsecond']
_ATTRS_PLURAL = ['{0}s'.format(a) for a in _ATTRS]
def __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0,
tzinfo=None):
if util.isstr(tzinfo):
tzinfo = parser.TzinfoParser.parse(tzinfo)
tzinfo = tzinfo or dateutil_tz.tzutc()
self._datetime = datetime(year, month, day, hour, minute, second,
microsecond, tzinfo)
# factories: single object, both original and from datetime.
@classmethod
def now(cls, tzinfo=None):
'''Constructs an :class:`Arrow ` object, representing "now".
:param tzinfo: (optional) a ``tzinfo`` object. Defaults to local time.
'''
utc = datetime.utcnow().replace(tzinfo=dateutil_tz.tzutc())
dt = utc.astimezone(dateutil_tz.tzlocal() if tzinfo is None else tzinfo)
return cls(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
dt.microsecond, dt.tzinfo)
@classmethod
def utcnow(cls):
''' Constructs an :class:`Arrow ` object, representing "now" in UTC
time.
'''
dt = datetime.utcnow()
return cls(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
dt.microsecond, dateutil_tz.tzutc())
@classmethod
def fromtimestamp(cls, timestamp, tzinfo=None):
''' Constructs an :class:`Arrow ` object from a timestamp.
:param timestamp: an ``int`` or ``float`` timestamp, or a ``str`` that converts to either.
:param tzinfo: (optional) a ``tzinfo`` object. Defaults to local time.
'''
tzinfo = tzinfo or dateutil_tz.tzlocal()
timestamp = cls._get_timestamp_from_input(timestamp)
dt = datetime.fromtimestamp(timestamp, tzinfo)
return cls(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
dt.microsecond, tzinfo)
@classmethod
def utcfromtimestamp(cls, timestamp):
'''Constructs an :class:`Arrow ` object from a timestamp, in UTC time.
:param timestamp: an ``int`` or ``float`` timestamp, or a ``str`` that converts to either.
'''
timestamp = cls._get_timestamp_from_input(timestamp)
dt = datetime.utcfromtimestamp(timestamp)
return cls(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
dt.microsecond, dateutil_tz.tzutc())
@classmethod
def fromdatetime(cls, dt, tzinfo=None):
''' Constructs an :class:`Arrow ` object from a ``datetime`` and optional
``tzinfo`` object.
:param dt: the ``datetime``
:param tzinfo: (optional) a ``tzinfo`` object. Defaults to UTC.
'''
tzinfo = tzinfo or dt.tzinfo or dateutil_tz.tzutc()
return cls(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
dt.microsecond, tzinfo)
@classmethod
def fromdate(cls, date, tzinfo=None):
''' Constructs an :class:`Arrow ` object from a ``date`` and optional
``tzinfo`` object. Time values are set to 0.
:param date: the ``date``
:param tzinfo: (optional) a ``tzinfo`` object. Defaults to UTC.
'''
tzinfo = tzinfo or dateutil_tz.tzutc()
return cls(date.year, date.month, date.day, tzinfo=tzinfo)
@classmethod
def strptime(cls, date_str, fmt, tzinfo=None):
''' Constructs an :class:`Arrow ` object from a date string and format,
in the style of ``datetime.strptime``.
:param date_str: the date string.
:param fmt: the format string.
:param tzinfo: (optional) an optional ``tzinfo``
'''
dt = datetime.strptime(date_str, fmt)
tzinfo = tzinfo or dt.tzinfo
return cls(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
dt.microsecond, tzinfo)
# factories: ranges and spans
@classmethod
def range(cls, frame, start, end=None, tz=None, limit=None):
''' Returns an array of :class:`Arrow ` objects, representing
an iteration of time between two inputs.
:param frame: the timeframe. Can be any ``datetime`` property (day, hour, minute...).
:param start: A datetime expression, the start of the range.
:param end: (optional) A datetime expression, the end of the range.
:param tz: (optional) A timezone expression. Defaults to UTC.
:param limit: (optional) A maximum number of tuples to return.
**NOTE**: the **end** or **limit** must be provided. Call with **end** alone to
return the entire range, with **limit** alone to return a maximum # of results from the
start, and with both to cap a range at a maximum # of results.
Supported frame values: year, quarter, month, week, day, hour, minute, second
Recognized datetime expressions:
- An :class:`Arrow ` object.
- A ``datetime`` object.
Recognized timezone expressions:
- A ``tzinfo`` object.
- A ``str`` describing a timezone, similar to 'US/Pacific', or 'Europe/Berlin'.
- A ``str`` in ISO-8601 style, as in '+07:00'.
- A ``str``, one of the following: 'local', 'utc', 'UTC'.
Usage:
>>> start = datetime(2013, 5, 5, 12, 30)
>>> end = datetime(2013, 5, 5, 17, 15)
>>> for r in arrow.Arrow.range('hour', start, end):
... print repr(r)
...
'''
_, frame_relative, relative_steps = cls._get_frames(frame)
tzinfo = cls._get_tzinfo(start.tzinfo if tz is None else tz)
start = cls._get_datetime(start).replace(tzinfo=tzinfo)
end, limit = cls._get_iteration_params(end, limit)
end = cls._get_datetime(end).replace(tzinfo=tzinfo)
current = cls.fromdatetime(start)
results = []
while current <= end and len(results) < limit:
results.append(current)
values = [getattr(current, f) for f in cls._ATTRS]
current = cls(*values, tzinfo=tzinfo) + relativedelta(**{frame_relative: relative_steps})
return results
@classmethod
def span_range(cls, frame, start, end, tz=None, limit=None):
''' Returns an array of tuples, each :class:`Arrow ` objects,
representing a series of timespans between two inputs.
:param frame: the timeframe. Can be any ``datetime`` property (day, hour, minute...).
:param start: A datetime expression, the start of the range.
:param end: (optional) A datetime expression, the end of the range.
:param tz: (optional) A timezone expression. Defaults to UTC.
:param limit: (optional) A maximum number of tuples to return.
**NOTE**: the **end** or **limit** must be provided. Call with **end** alone to
return the entire range, with **limit** alone to return a maximum # of results from the
start, and with both to cap a range at a maximum # of results.
Supported frame values: year, quarter, month, week, day, hour, minute, second
Recognized datetime expressions:
- An :class:`Arrow ` object.
- A ``datetime`` object.
Recognized timezone expressions:
- A ``tzinfo`` object.
- A ``str`` describing a timezone, similar to 'US/Pacific', or 'Europe/Berlin'.
- A ``str`` in ISO-8601 style, as in '+07:00'.
- A ``str``, one of the following: 'local', 'utc', 'UTC'.
Usage:
>>> start = datetime(2013, 5, 5, 12, 30)
>>> end = datetime(2013, 5, 5, 17, 15)
>>> for r in arrow.Arrow.span_range('hour', start, end):
... print r
...
(, )
(, )
(, )
(, )
(, )
'''
tzinfo = cls._get_tzinfo(start.tzinfo if tz is None else tz)
start = cls.fromdatetime(start, tzinfo).span(frame)[0]
_range = cls.range(frame, start, end, tz, limit)
return [r.span(frame) for r in _range]
# representations
def __repr__(self):
dt = self._datetime
attrs = ', '.join([str(i) for i in [dt.year, dt.month, dt.day, dt.hour, dt.minute,
dt.second, dt.microsecond]])
return '<{0} [{1}]>'.format(self.__class__.__name__, self.__str__())
def __str__(self):
return self._datetime.isoformat()
def __format__(self, formatstr):
if len(formatstr) > 0:
return self.format(formatstr)
return str(self)
def __hash__(self):
return self._datetime.__hash__()
# attributes & properties
def __getattr__(self, name):
if name == 'week':
return self.isocalendar()[1]
if not name.startswith('_'):
value = getattr(self._datetime, name, None)
if value is not None:
return value
return object.__getattribute__(self, name)
@property
def tzinfo(self):
''' Gets the ``tzinfo`` of the :class:`Arrow ` object. '''
return self._datetime.tzinfo
@tzinfo.setter
def tzinfo(self, tzinfo):
''' Sets the ``tzinfo`` of the :class:`Arrow ` object. '''
self._datetime = self._datetime.replace(tzinfo=tzinfo)
@property
def datetime(self):
''' Returns a datetime representation of the :class:`Arrow ` object. '''
return self._datetime
@property
def naive(self):
''' Returns a naive datetime representation of the :class:`Arrow ` object. '''
return self._datetime.replace(tzinfo=None)
@property
def timestamp(self):
''' Returns a timestamp representation of the :class:`Arrow ` object. '''
return calendar.timegm(self._datetime.utctimetuple())
@property
def float_timestamp(self):
''' Returns a floating-point representation of the :class:`Arrow ` object. '''
return self.timestamp + float(self.microsecond) / 1000000
# mutation and duplication.
def clone(self):
''' Returns a new :class:`Arrow ` object, cloned from the current one.
Usage:
>>> arw = arrow.utcnow()
>>> cloned = arw.clone()
'''
return self.fromdatetime(self._datetime)
def replace(self, **kwargs):
''' Returns a new :class:`Arrow ` object with attributes updated
according to inputs.
Use single property names to set their value absolutely:
>>> import arrow
>>> arw = arrow.utcnow()
>>> arw
>>> arw.replace(year=2014, month=6)
Use plural property names to shift their current value relatively:
>>> arw.replace(years=1, months=-1)
You can also provide a timezone expression can also be replaced:
>>> arw.replace(tzinfo=tz.tzlocal())
Recognized timezone expressions:
- A ``tzinfo`` object.
- A ``str`` describing a timezone, similar to 'US/Pacific', or 'Europe/Berlin'.
- A ``str`` in ISO-8601 style, as in '+07:00'.
- A ``str``, one of the following: 'local', 'utc', 'UTC'.
'''
absolute_kwargs = {}
relative_kwargs = {}
for key, value in kwargs.items():
if key in self._ATTRS:
absolute_kwargs[key] = value
elif key in self._ATTRS_PLURAL or key == 'weeks':
relative_kwargs[key] = value
elif key == 'week':
raise AttributeError('setting absolute week is not supported')
elif key !='tzinfo':
raise AttributeError()
current = self._datetime.replace(**absolute_kwargs)
current += relativedelta(**relative_kwargs)
tzinfo = kwargs.get('tzinfo')
if tzinfo is not None:
tzinfo = self._get_tzinfo(tzinfo)
current = current.replace(tzinfo=tzinfo)
return self.fromdatetime(current)
def to(self, tz):
''' Returns a new :class:`Arrow ` object, converted to the target
timezone.
:param tz: an expression representing a timezone.
Recognized timezone expressions:
- A ``tzinfo`` object.
- A ``str`` describing a timezone, similar to 'US/Pacific', or 'Europe/Berlin'.
- A ``str`` in ISO-8601 style, as in '+07:00'.
- A ``str``, one of the following: 'local', 'utc', 'UTC'.
Usage::
>>> utc = arrow.utcnow()
>>> utc
>>> utc.to('US/Pacific')
>>> utc.to(tz.tzlocal())
>>> utc.to('-07:00')
>>> utc.to('local')
>>> utc.to('local').to('utc')
'''
if not isinstance(tz, tzinfo):
tz = parser.TzinfoParser.parse(tz)
dt = self._datetime.astimezone(tz)
return self.__class__(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
dt.microsecond, dt.tzinfo)
def span(self, frame, count=1):
''' Returns two new :class:`Arrow ` objects, representing the timespan
of the :class:`Arrow ` object in a given timeframe.
:param frame: the timeframe. Can be any ``datetime`` property (day, hour, minute...).
:param count: (optional) the number of frames to span.
Supported frame values: year, quarter, month, week, day, hour, minute, second
Usage::
>>> arrow.utcnow()
>>> arrow.utcnow().span('hour')
(, )
>>> arrow.utcnow().span('day')
(, )
>>> arrow.utcnow().span('day', count=2)
(, )
'''
frame_absolute, frame_relative, relative_steps = self._get_frames(frame)
if frame_absolute == 'week':
attr = 'day'
elif frame_absolute == 'quarter':
attr = 'month'
else:
attr = frame_absolute
index = self._ATTRS.index(attr)
frames = self._ATTRS[:index + 1]
values = [getattr(self, f) for f in frames]
for i in range(3 - len(values)):
values.append(1)
floor = self.__class__(*values, tzinfo=self.tzinfo)
if frame_absolute == 'week':
floor = floor + relativedelta(days=-(self.isoweekday() - 1))
elif frame_absolute == 'quarter':
floor = floor + relativedelta(months=-((self.month - 1) % 3))
ceil = floor + relativedelta(
**{frame_relative: count * relative_steps}) + relativedelta(microseconds=-1)
return floor, ceil
def floor(self, frame):
''' Returns a new :class:`Arrow ` object, representing the "floor"
of the timespan of the :class:`Arrow ` object in a given timeframe.
Equivalent to the first element in the 2-tuple returned by
:func:`span `.
:param frame: the timeframe. Can be any ``datetime`` property (day, hour, minute...).
Usage::
>>> arrow.utcnow().floor('hour')
'''
return self.span(frame)[0]
def ceil(self, frame):
''' Returns a new :class:`Arrow ` object, representing the "ceiling"
of the timespan of the :class:`Arrow ` object in a given timeframe.
Equivalent to the second element in the 2-tuple returned by
:func:`span `.
:param frame: the timeframe. Can be any ``datetime`` property (day, hour, minute...).
Usage::
>>> arrow.utcnow().ceil('hour')
'''
return self.span(frame)[1]
# string output and formatting.
def format(self, fmt='YYYY-MM-DD HH:mm:ssZZ', locale='en_us'):
''' Returns a string representation of the :class:`Arrow ` object,
formatted according to a format string.
:param fmt: the format string.
Usage::
>>> arrow.utcnow().format('YYYY-MM-DD HH:mm:ss ZZ')
'2013-05-09 03:56:47 -00:00'
>>> arrow.utcnow().format('X')
'1368071882'
>>> arrow.utcnow().format('MMMM DD, YYYY')
'May 09, 2013'
>>> arrow.utcnow().format()
'2013-05-09 03:56:47 -00:00'
'''
return formatter.DateTimeFormatter(locale).format(self._datetime, fmt)
def humanize(self, other=None, locale='en_us', only_distance=False):
''' Returns a localized, humanized representation of a relative difference in time.
:param other: (optional) an :class:`Arrow ` or ``datetime`` object.
Defaults to now in the current :class:`Arrow ` object's timezone.
:param locale: (optional) a ``str`` specifying a locale. Defaults to 'en_us'.
:param only_difference: (optional) returns only time difference eg: "11 seconds" without "in" or "ago" part.
Usage::
>>> earlier = arrow.utcnow().replace(hours=-2)
>>> earlier.humanize()
'2 hours ago'
>>> later = later = earlier.replace(hours=4)
>>> later.humanize(earlier)
'in 4 hours'
'''
locale = locales.get_locale(locale)
if other is None:
utc = datetime.utcnow().replace(tzinfo=dateutil_tz.tzutc())
dt = utc.astimezone(self._datetime.tzinfo)
elif isinstance(other, Arrow):
dt = other._datetime
elif isinstance(other, datetime):
if other.tzinfo is None:
dt = other.replace(tzinfo=self._datetime.tzinfo)
else:
dt = other.astimezone(self._datetime.tzinfo)
else:
raise TypeError()
delta = int(util.total_seconds(self._datetime - dt))
sign = -1 if delta < 0 else 1
diff = abs(delta)
delta = diff
if diff < 10:
return locale.describe('now', only_distance=only_distance)
if diff < 45:
return locale.describe('seconds', sign, only_distance=only_distance)
elif diff < 90:
return locale.describe('minute', sign, only_distance=only_distance)
elif diff < 2700:
minutes = sign * int(max(delta / 60, 2))
return locale.describe('minutes', minutes, only_distance=only_distance)
elif diff < 5400:
return locale.describe('hour', sign, only_distance=only_distance)
elif diff < 79200:
hours = sign * int(max(delta / 3600, 2))
return locale.describe('hours', hours, only_distance=only_distance)
elif diff < 129600:
return locale.describe('day', sign, only_distance=only_distance)
elif diff < 2160000:
days = sign * int(max(delta / 86400, 2))
return locale.describe('days', days, only_distance=only_distance)
elif diff < 3888000:
return locale.describe('month', sign, only_distance=only_distance)
elif diff < 29808000:
self_months = self._datetime.year * 12 + self._datetime.month
other_months = dt.year * 12 + dt.month
months = sign * abs(other_months - self_months)
return locale.describe('months', months, only_distance=only_distance)
elif diff < 47260800:
return locale.describe('year', sign, only_distance=only_distance)
else:
years = sign * int(max(delta / 31536000, 2))
return locale.describe('years', years, only_distance=only_distance)
# math
def __add__(self, other):
if isinstance(other, (timedelta, relativedelta)):
return self.fromdatetime(self._datetime + other, self._datetime.tzinfo)
raise TypeError()
def __radd__(self, other):
return self.__add__(other)
def __sub__(self, other):
if isinstance(other, timedelta):
return self.fromdatetime(self._datetime - other, self._datetime.tzinfo)
elif isinstance(other, datetime):
return self._datetime - other
elif isinstance(other, Arrow):
return self._datetime - other._datetime
raise TypeError()
def __rsub__(self, other):
return self.__sub__(other)
# comparisons
def _cmperror(self, other):
raise TypeError('can\'t compare \'{0}\' to \'{1}\''.format(
type(self), type(other)))
def __eq__(self, other):
if not isinstance(other, (Arrow, datetime)):
return False
other = self._get_datetime(other)
return self._datetime == self._get_datetime(other)
def __ne__(self, other):
return not self.__eq__(other)
def __gt__(self, other):
if not isinstance(other, (Arrow, datetime)):
self._cmperror(other)
return self._datetime > self._get_datetime(other)
def __ge__(self, other):
if not isinstance(other, (Arrow, datetime)):
self._cmperror(other)
return self._datetime >= self._get_datetime(other)
def __lt__(self, other):
if not isinstance(other, (Arrow, datetime)):
self._cmperror(other)
return self._datetime < self._get_datetime(other)
def __le__(self, other):
if not isinstance(other, (Arrow, datetime)):
self._cmperror(other)
return self._datetime <= self._get_datetime(other)
# datetime methods
def date(self):
''' Returns a ``date`` object with the same year, month and day. '''
return self._datetime.date()
def time(self):
''' Returns a ``time`` object with the same hour, minute, second, microsecond. '''
return self._datetime.time()
def timetz(self):
''' Returns a ``time`` object with the same hour, minute, second, microsecond and tzinfo. '''
return self._datetime.timetz()
def astimezone(self, tz):
''' Returns a ``datetime`` object, adjusted to the specified tzinfo.
:param tz: a ``tzinfo`` object.
'''
return self._datetime.astimezone(tz)
def utcoffset(self):
''' Returns a ``timedelta`` object representing the whole number of minutes difference from UTC time. '''
return self._datetime.utcoffset()
def dst(self):
''' Returns the daylight savings time adjustment. '''
return self._datetime.dst()
def timetuple(self):
''' Returns a ``time.struct_time``, in the current timezone. '''
return self._datetime.timetuple()
def utctimetuple(self):
''' Returns a ``time.struct_time``, in UTC time. '''
return self._datetime.utctimetuple()
def toordinal(self):
''' Returns the proleptic Gregorian ordinal of the date. '''
return self._datetime.toordinal()
def weekday(self):
''' Returns the day of the week as an integer (0-6). '''
return self._datetime.weekday()
def isoweekday(self):
''' Returns the ISO day of the week as an integer (1-7). '''
return self._datetime.isoweekday()
def isocalendar(self):
''' Returns a 3-tuple, (ISO year, ISO week number, ISO weekday). '''
return self._datetime.isocalendar()
def isoformat(self, sep='T'):
'''Returns an ISO 8601 formatted representation of the date and time. '''
return self._datetime.isoformat(sep)
def ctime(self):
''' Returns a ctime formatted representation of the date and time. '''
return self._datetime.ctime()
def strftime(self, format):
''' Formats in the style of ``datetime.strptime``.
:param format: the format string.
'''
return self._datetime.strftime(format)
def for_json(self):
'''Serializes for the ``for_json`` protocol of simplejson.'''
return self.isoformat()
# internal tools.
@staticmethod
def _get_tzinfo(tz_expr):
if tz_expr is None:
return dateutil_tz.tzutc()
if isinstance(tz_expr, tzinfo):
return tz_expr
else:
try:
return parser.TzinfoParser.parse(tz_expr)
except parser.ParserError:
raise ValueError('\'{0}\' not recognized as a timezone')
@classmethod
def _get_datetime(cls, expr):
if isinstance(expr, Arrow):
return expr.datetime
if isinstance(expr, datetime):
return expr
try:
expr = float(expr)
return cls.utcfromtimestamp(expr).datetime
except:
raise ValueError('\'{0}\' not recognized as a timestamp or datetime')
@classmethod
def _get_frames(cls, name):
if name in cls._ATTRS:
return name, '{0}s'.format(name), 1
elif name in ['week', 'weeks']:
return 'week', 'weeks', 1
elif name in ['quarter', 'quarters']:
return 'quarter', 'months', 3
raise AttributeError()
@classmethod
def _get_iteration_params(cls, end, limit):
if end is None:
if limit is None:
raise Exception('one of \'end\' or \'limit\' is required')
return cls.max, limit
else:
return end, sys.maxsize
@staticmethod
def _get_timestamp_from_input(timestamp):
try:
return float(timestamp)
except:
raise ValueError('cannot parse \'{0}\' as a timestamp'.format(timestamp))
Arrow.min = Arrow.fromdatetime(datetime.min)
Arrow.max = Arrow.fromdatetime(datetime.max)
arrow-0.7.0/arrow/factory.py 0000664 0000000 0000000 00000020326 12605232351 0016025 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
"""
Implements the :class:`ArrowFactory ` class,
providing factory methods for common :class:`Arrow `
construction scenarios.
"""
from __future__ import absolute_import
from arrow.arrow import Arrow
from arrow import parser
from arrow.util import is_timestamp, isstr
from datetime import datetime, tzinfo, date
from dateutil import tz as dateutil_tz
from time import struct_time
import calendar
class ArrowFactory(object):
''' A factory for generating :class:`Arrow ` objects.
:param type: (optional) the :class:`Arrow `-based class to construct from.
Defaults to :class:`Arrow `.
'''
def __init__(self, type=Arrow):
self.type = type
def get(self, *args, **kwargs):
''' Returns an :class:`Arrow ` object based on flexible inputs.
Usage::
>>> import arrow
**No inputs** to get current UTC time::
>>> arrow.get()
**None** to also get current UTC time::
>>> arrow.get(None)
**One** :class:`Arrow ` object, to get a copy.
>>> arw = arrow.utcnow()
>>> arrow.get(arw)
**One** ``str``, ``float``, or ``int``, convertible to a floating-point timestamp, to get that timestamp in UTC::
>>> arrow.get(1367992474.293378)
>>> arrow.get(1367992474)
>>> arrow.get('1367992474.293378')
>>> arrow.get('1367992474')
**One** ISO-8601-formatted ``str``, to parse it::
>>> arrow.get('2013-09-29T01:26:43.830580')
**One** ``tzinfo``, to get the current time in that timezone::
>>> arrow.get(tz.tzlocal())
**One** naive ``datetime``, to get that datetime in UTC::
>>> arrow.get(datetime(2013, 5, 5))
**One** aware ``datetime``, to get that datetime::
>>> arrow.get(datetime(2013, 5, 5, tzinfo=tz.tzlocal()))
**One** naive ``date``, to get that date in UTC::
>>> arrow.get(date(2013, 5, 5))
**Two** arguments, a naive or aware ``datetime``, and a timezone expression (as above)::
>>> arrow.get(datetime(2013, 5, 5), 'US/Pacific')
**Two** arguments, a naive ``date``, and a timezone expression (as above)::
>>> arrow.get(date(2013, 5, 5), 'US/Pacific')
**Two** arguments, both ``str``, to parse the first according to the format of the second::
>>> arrow.get('2013-05-05 12:30:45', 'YYYY-MM-DD HH:mm:ss')
**Two** arguments, first a ``str`` to parse and second a ``list`` of formats to try::
>>> arrow.get('2013-05-05 12:30:45', ['MM/DD/YYYY', 'YYYY-MM-DD HH:mm:ss'])
**Three or more** arguments, as for the constructor of a ``datetime``::
>>> arrow.get(2013, 5, 5, 12, 30, 45)
**One** time.struct time::
>>> arrow.get(gmtime(0))
'''
arg_count = len(args)
locale = kwargs.get('locale', 'en_us')
tz = kwargs.get('tzinfo', None)
# () -> now, @ utc.
if arg_count == 0:
if isinstance(tz, tzinfo):
return self.type.now(tz)
return self.type.utcnow()
if arg_count == 1:
arg = args[0]
# (None) -> now, @ utc.
if arg is None:
return self.type.utcnow()
# try (int, float, str(int), str(float)) -> utc, from timestamp.
if is_timestamp(arg):
return self.type.utcfromtimestamp(arg)
# (Arrow) -> from the object's datetime.
if isinstance(arg, Arrow):
return self.type.fromdatetime(arg.datetime)
# (datetime) -> from datetime.
if isinstance(arg, datetime):
return self.type.fromdatetime(arg)
# (date) -> from date.
if isinstance(arg, date):
return self.type.fromdate(arg)
# (tzinfo) -> now, @ tzinfo.
elif isinstance(arg, tzinfo):
return self.type.now(arg)
# (str) -> now, @ tzinfo.
elif isstr(arg):
dt = parser.DateTimeParser(locale).parse_iso(arg)
return self.type.fromdatetime(dt)
# (struct_time) -> from struct_time
elif isinstance(arg, struct_time):
return self.type.utcfromtimestamp(calendar.timegm(arg))
else:
raise TypeError('Can\'t parse single argument type of \'{0}\''.format(type(arg)))
elif arg_count == 2:
arg_1, arg_2 = args[0], args[1]
if isinstance(arg_1, datetime):
# (datetime, tzinfo) -> fromdatetime @ tzinfo/string.
if isinstance(arg_2, tzinfo) or isstr(arg_2):
return self.type.fromdatetime(arg_1, arg_2)
else:
raise TypeError('Can\'t parse two arguments of types \'datetime\', \'{0}\''.format(
type(arg_2)))
# (date, tzinfo/str) -> fromdate @ tzinfo/string.
elif isinstance(arg_1, date):
if isinstance(arg_2, tzinfo) or isstr(arg_2):
return self.type.fromdate(arg_1, tzinfo=arg_2)
else:
raise TypeError('Can\'t parse two arguments of types \'date\', \'{0}\''.format(
type(arg_2)))
# (str, format) -> parse.
elif isstr(arg_1) and (isstr(arg_2) or isinstance(arg_2, list)):
dt = parser.DateTimeParser(locale).parse(args[0], args[1])
return self.type.fromdatetime(dt, tzinfo=tz)
else:
raise TypeError('Can\'t parse two arguments of types \'{0}\', \'{1}\''.format(
type(arg_1), type(arg_2)))
# 3+ args -> datetime-like via constructor.
else:
return self.type(*args, **kwargs)
def utcnow(self):
'''Returns an :class:`Arrow ` object, representing "now" in UTC time.
Usage::
>>> import arrow
>>> arrow.utcnow()
'''
return self.type.utcnow()
def now(self, tz=None):
'''Returns an :class:`Arrow ` object, representing "now".
:param tz: (optional) An expression representing a timezone. Defaults to local time.
Recognized timezone expressions:
- A ``tzinfo`` object.
- A ``str`` describing a timezone, similar to 'US/Pacific', or 'Europe/Berlin'.
- A ``str`` in ISO-8601 style, as in '+07:00'.
- A ``str``, one of the following: 'local', 'utc', 'UTC'.
Usage::
>>> import arrow
>>> arrow.now()
>>> arrow.now('US/Pacific')
>>> arrow.now('+02:00')
>>> arrow.now('local')
'''
if tz is None:
tz = dateutil_tz.tzlocal()
elif not isinstance(tz, tzinfo):
tz = parser.TzinfoParser.parse(tz)
return self.type.now(tz)
arrow-0.7.0/arrow/formatter.py 0000664 0000000 0000000 00000006551 12605232351 0016365 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
from __future__ import absolute_import
import calendar
import re
from dateutil import tz as dateutil_tz
from arrow import util, locales
class DateTimeFormatter(object):
_FORMAT_RE = re.compile('(YYY?Y?|MM?M?M?|Do|DD?D?D?|d?dd?d?|HH?|hh?|mm?|ss?|SS?S?S?S?S?|ZZ?|a|A|X)')
def __init__(self, locale='en_us'):
self.locale = locales.get_locale(locale)
def format(cls, dt, fmt):
return cls._FORMAT_RE.sub(lambda m: cls._format_token(dt, m.group(0)), fmt)
def _format_token(self, dt, token):
if token == 'YYYY':
return self.locale.year_full(dt.year)
if token == 'YY':
return self.locale.year_abbreviation(dt.year)
if token == 'MMMM':
return self.locale.month_name(dt.month)
if token == 'MMM':
return self.locale.month_abbreviation(dt.month)
if token == 'MM':
return '{0:02d}'.format(dt.month)
if token == 'M':
return str(dt.month)
if token == 'DDDD':
return '{0:03d}'.format(dt.timetuple().tm_yday)
if token == 'DDD':
return str(dt.timetuple().tm_yday)
if token == 'DD':
return '{0:02d}'.format(dt.day)
if token == 'D':
return str(dt.day)
if token == 'Do':
return self.locale.ordinal_number(dt.day)
if token == 'dddd':
return self.locale.day_name(dt.isoweekday())
if token == 'ddd':
return self.locale.day_abbreviation(dt.isoweekday())
if token == 'd':
return str(dt.isoweekday())
if token == 'HH':
return '{0:02d}'.format(dt.hour)
if token == 'H':
return str(dt.hour)
if token == 'hh':
return '{0:02d}'.format(dt.hour if 0 < dt.hour < 13 else abs(dt.hour - 12))
if token == 'h':
return str(dt.hour if 0 < dt.hour < 13 else abs(dt.hour - 12))
if token == 'mm':
return '{0:02d}'.format(dt.minute)
if token == 'm':
return str(dt.minute)
if token == 'ss':
return '{0:02d}'.format(dt.second)
if token == 's':
return str(dt.second)
if token == 'SSSSSS':
return str('{0:06d}'.format(int(dt.microsecond)))
if token == 'SSSSS':
return str('{0:05d}'.format(int(dt.microsecond / 10)))
if token == 'SSSS':
return str('{0:04d}'.format(int(dt.microsecond / 100)))
if token == 'SSS':
return str('{0:03d}'.format(int(dt.microsecond / 1000)))
if token == 'SS':
return str('{0:02d}'.format(int(dt.microsecond / 10000)))
if token == 'S':
return str(int(dt.microsecond / 100000))
if token == 'X':
return str(calendar.timegm(dt.utctimetuple()))
if token in ['ZZ', 'Z']:
separator = ':' if token == 'ZZ' else ''
tz = dateutil_tz.tzutc() if dt.tzinfo is None else dt.tzinfo
total_minutes = int(util.total_seconds(tz.utcoffset(dt)) / 60)
sign = '+' if total_minutes > 0 else '-'
total_minutes = abs(total_minutes)
hour, minute = divmod(total_minutes, 60)
return '{0}{1:02d}{2}{3:02d}'.format(sign, hour, separator, minute)
if token in ('a', 'A'):
return self.locale.meridian(dt.hour, token)
arrow-0.7.0/arrow/locales.py 0000664 0000000 0000000 00000152717 12605232351 0016012 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import calendar
import inspect
import sys
def get_locale(name):
'''Returns an appropriate :class:`Locale ` corresponding
to an inpute locale name.
:param name: the name of the locale.
'''
locale_cls = _locales.get(name.lower())
if locale_cls is None:
raise ValueError('Unsupported locale \'{0}\''.format(name))
return locale_cls()
# base locale type.
class Locale(object):
''' Represents locale-specific data and functionality. '''
names = []
timeframes = {
'now': '',
'seconds': '',
'minute': '',
'minutes': '',
'hour': '',
'hours': '',
'day': '',
'days': '',
'month': '',
'months': '',
'year': '',
'years': '',
}
meridians = {
'am': '',
'pm': '',
'AM': '',
'PM': '',
}
past = None
future = None
month_names = []
month_abbreviations = []
day_names = []
day_abbreviations = []
ordinal_day_re = r'(\d+)'
def __init__(self):
self._month_name_to_ordinal = None
def describe(self, timeframe, delta=0, only_distance=False):
''' Describes a delta within a timeframe in plain language.
:param timeframe: a string representing a timeframe.
:param delta: a quantity representing a delta in a timeframe.
:param only_distance: return only distance eg: "11 seconds" without "in" or "ago" keywords
'''
humanized = self._format_timeframe(timeframe, delta)
if not only_distance:
humanized = self._format_relative(humanized, timeframe, delta)
return humanized
def day_name(self, day):
''' Returns the day name for a specified day of the week.
:param day: the ``int`` day of the week (1-7).
'''
return self.day_names[day]
def day_abbreviation(self, day):
''' Returns the day abbreviation for a specified day of the week.
:param day: the ``int`` day of the week (1-7).
'''
return self.day_abbreviations[day]
def month_name(self, month):
''' Returns the month name for a specified month of the year.
:param month: the ``int`` month of the year (1-12).
'''
return self.month_names[month]
def month_abbreviation(self, month):
''' Returns the month abbreviation for a specified month of the year.
:param month: the ``int`` month of the year (1-12).
'''
return self.month_abbreviations[month]
def month_number(self, name):
''' Returns the month number for a month specified by name or abbreviation.
:param name: the month name or abbreviation.
'''
if self._month_name_to_ordinal is None:
self._month_name_to_ordinal = self._name_to_ordinal(self.month_names)
self._month_name_to_ordinal.update(self._name_to_ordinal(self.month_abbreviations))
return self._month_name_to_ordinal.get(name)
def year_full(self, year):
''' Returns the year for specific locale if available
:param name: the ``int`` year (4-digit)
'''
return '{0:04d}'.format(year)
def year_abbreviation(self, year):
''' Returns the year for specific locale if available
:param name: the ``int`` year (4-digit)
'''
return '{0:04d}'.format(year)[2:]
def meridian(self, hour, token):
''' Returns the meridian indicator for a specified hour and format token.
:param hour: the ``int`` hour of the day.
:param token: the format token.
'''
if token == 'a':
return self.meridians['am'] if hour < 12 else self.meridians['pm']
if token == 'A':
return self.meridians['AM'] if hour < 12 else self.meridians['PM']
def ordinal_number(self, n):
''' Returns the ordinal format of a given integer
:param n: an integer
'''
return self._ordinal_number(n)
def _ordinal_number(self, n):
return '{0}'.format(n)
def _name_to_ordinal(self, lst):
return dict(map(lambda i: (i[1], i[0] + 1), enumerate(lst[1:])))
def _format_timeframe(self, timeframe, delta):
return self.timeframes[timeframe].format(abs(delta))
def _format_relative(self, humanized, timeframe, delta):
if timeframe == 'now':
return humanized
direction = self.past if delta < 0 else self.future
return direction.format(humanized)
# base locale type implementations.
class EnglishLocale(Locale):
names = ['en', 'en_us', 'en_gb', 'en_au', 'en_be', 'en_jp', 'en_za']
past = '{0} ago'
future = 'in {0}'
timeframes = {
'now': 'just now',
'seconds': 'seconds',
'minute': 'a minute',
'minutes': '{0} minutes',
'hour': 'an hour',
'hours': '{0} hours',
'day': 'a day',
'days': '{0} days',
'month': 'a month',
'months': '{0} months',
'year': 'a year',
'years': '{0} years',
}
meridians = {
'am': 'am',
'pm': 'pm',
'AM': 'AM',
'PM': 'PM',
}
month_names = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
month_abbreviations = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec']
day_names = ['', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
day_abbreviations = ['', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
ordinal_day_re = r'((?P[2-3]?1(?=st)|[2-3]?2(?=nd)|[2-3]?3(?=rd)|[1-3]?[04-9](?=th)|1[1-3](?=th))(st|nd|rd|th))'
def _ordinal_number(self, n):
if n % 100 not in (11, 12, 13):
remainder = abs(n) % 10
if remainder == 1:
return '{0}st'.format(n)
elif remainder == 2:
return '{0}nd'.format(n)
elif remainder == 3:
return '{0}rd'.format(n)
return '{0}th'.format(n)
class ItalianLocale(Locale):
names = ['it', 'it_it']
past = '{0} fa'
future = 'tra {0}'
timeframes = {
'now': 'adesso',
'seconds': 'qualche secondo',
'minute': 'un minuto',
'minutes': '{0} minuti',
'hour': 'un\'ora',
'hours': '{0} ore',
'day': 'un giorno',
'days': '{0} giorni',
'month': 'un mese',
'months': '{0} mesi',
'year': 'un anno',
'years': '{0} anni',
}
month_names = ['', 'Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio',
'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre']
month_abbreviations = ['', 'Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago',
'Set', 'Ott', 'Nov', 'Dic']
day_names = ['', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato', 'Domenica']
day_abbreviations = ['', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab', 'Dom']
ordinal_day_re = r'((?P[1-3]?[0-9](?=°))°)'
def _ordinal_number(self, n):
return '{0}°'.format(n)
class SpanishLocale(Locale):
names = ['es', 'es_es']
past = 'hace {0}'
future = 'en {0}'
timeframes = {
'now': 'ahora',
'seconds': 'segundos',
'minute': 'un minuto',
'minutes': '{0} minutos',
'hour': 'una hora',
'hours': '{0} horas',
'day': 'un día',
'days': '{0} días',
'month': 'un mes',
'months': '{0} meses',
'year': 'un año',
'years': '{0} años',
}
month_names = ['', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio',
'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre']
month_abbreviations = ['', 'Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago',
'Sep', 'Oct', 'Nov', 'Dic']
day_names = ['', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Domingo']
day_abbreviations = ['', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab', 'Dom']
ordinal_day_re = r'((?P[1-3]?[0-9](?=°))°)'
def _ordinal_number(self, n):
return '{0}°'.format(n)
class FrenchLocale(Locale):
names = ['fr', 'fr_fr']
past = 'il y a {0}'
future = 'dans {0}'
timeframes = {
'now': 'maintenant',
'seconds': 'quelques secondes',
'minute': 'une minute',
'minutes': '{0} minutes',
'hour': 'une heure',
'hours': '{0} heures',
'day': 'un jour',
'days': '{0} jours',
'month': 'un mois',
'months': '{0} mois',
'year': 'un an',
'years': '{0} ans',
}
month_names = ['', 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet',
'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre']
month_abbreviations = ['', 'Janv', 'Févr', 'Mars', 'Avr', 'Mai', 'Juin', 'Juil', 'Août',
'Sept', 'Oct', 'Nov', 'Déc']
day_names = ['', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche']
day_abbreviations = ['', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim']
ordinal_day_re = r'((?P\b1(?=er\b)|[1-3]?[02-9](?=e\b)|[1-3]1(?=e\b))(er|e)\b)'
def _ordinal_number(self, n):
if abs(n) == 1:
return '{0}er'.format(n)
return '{0}e'.format(n)
class GreekLocale(Locale):
names = ['el', 'el_gr']
past = '{0} πριν'
future = 'σε {0}'
timeframes = {
'now': 'τώρα',
'seconds': 'δευτερόλεπτα',
'minute': 'ένα λεπτό',
'minutes': '{0} λεπτά',
'hour': 'μια ώρα',
'hours': '{0} ώρες',
'day': 'μια μέρα',
'days': '{0} μέρες',
'month': 'ένα μήνα',
'months': '{0} μήνες',
'year': 'ένα χρόνο',
'years': '{0} χρόνια',
}
month_names = ['', 'Ιανουαρίου', 'Φεβρουαρίου', 'Μαρτίου', 'Απριλίου', 'Μαΐου', 'Ιουνίου',
'Ιουλίου', 'Αυγούστου', 'Σεπτεμβρίου', 'Οκτωβρίου', 'Νοεμβρίου', 'Δεκεμβρίου']
month_abbreviations = ['', 'Ιαν', 'Φεβ', 'Μαρ', 'Απρ', 'Μαϊ', 'Ιον', 'Ιολ', 'Αυγ',
'Σεπ', 'Οκτ', 'Νοε', 'Δεκ']
day_names = ['', 'Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο', 'Κυριακή']
day_abbreviations = ['', 'Δευ', 'Τρι', 'Τετ', 'Πεμ', 'Παρ', 'Σαβ', 'Κυρ']
class JapaneseLocale(Locale):
names = ['ja', 'ja_jp']
past = '{0}前'
future = '{0}後'
timeframes = {
'now': '現在',
'seconds': '秒',
'minute': '1分',
'minutes': '{0}分',
'hour': '1時間',
'hours': '{0}時間',
'day': '1日',
'days': '{0}日',
'month': '1ヶ月',
'months': '{0}ヶ月',
'year': '1年',
'years': '{0}年',
}
month_names = ['', '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月',
'9月', '10月', '11月', '12月']
month_abbreviations = ['', ' 1', ' 2', ' 3', ' 4', ' 5', ' 6', ' 7', ' 8',
' 9', '10', '11', '12']
day_names = ['', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日', '日曜日']
day_abbreviations = ['', '月', '火', '水', '木', '金', '土', '日']
class SwedishLocale(Locale):
names = ['sv', 'sv_se']
past = 'för {0} sen'
future = 'om {0}'
timeframes = {
'now': 'just nu',
'seconds': 'några sekunder',
'minute': 'en minut',
'minutes': '{0} minuter',
'hour': 'en timme',
'hours': '{0} timmar',
'day': 'en dag',
'days': '{0} dagar',
'month': 'en månad',
'months': '{0} månader',
'year': 'ett år',
'years': '{0} år',
}
month_names = ['', 'Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli',
'Augusti', 'September', 'Oktober', 'November', 'December']
month_abbreviations = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul',
'Aug', 'Sep', 'Okt', 'Nov', 'Dec']
day_names = ['', 'Måndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lördag', 'Söndag']
day_abbreviations = ['', 'Mån', 'Tis', 'Ons', 'Tor', 'Fre', 'Lör', 'Sön']
class FinnishLocale(Locale):
names = ['fi', 'fi_fi']
# The finnish grammar is very complex, and its hard to convert
# 1-to-1 to something like English.
past = '{0} sitten'
future = '{0} kuluttua'
timeframes = {
'now': ['juuri nyt', 'juuri nyt'],
'seconds': ['muutama sekunti', 'muutaman sekunnin'],
'minute': ['minuutti', 'minuutin'],
'minutes': ['{0} minuuttia', '{0} minuutin'],
'hour': ['tunti', 'tunnin'],
'hours': ['{0} tuntia', '{0} tunnin'],
'day': ['päivä', 'päivä'],
'days': ['{0} päivää', '{0} päivän'],
'month': ['kuukausi', 'kuukauden'],
'months': ['{0} kuukautta', '{0} kuukauden'],
'year': ['vuosi', 'vuoden'],
'years': ['{0} vuotta', '{0} vuoden'],
}
# Months and days are lowercase in Finnish
month_names = ['', 'tammikuu', 'helmikuu', 'maaliskuu', 'huhtikuu',
'toukokuu', 'kesäkuu', 'heinäkuu', 'elokuu',
'syyskuu', 'lokakuu', 'marraskuu', 'joulukuu']
month_abbreviations = ['', 'tammi', 'helmi', 'maalis', 'huhti',
'touko', 'kesä', 'heinä', 'elo',
'syys', 'loka', 'marras', 'joulu']
day_names = ['', 'maanantai', 'tiistai', 'keskiviikko', 'torstai',
'perjantai', 'lauantai', 'sunnuntai']
day_abbreviations = ['', 'ma', 'ti', 'ke', 'to', 'pe', 'la', 'su']
def _format_timeframe(self, timeframe, delta):
return (self.timeframes[timeframe][0].format(abs(delta)),
self.timeframes[timeframe][1].format(abs(delta)))
def _format_relative(self, humanized, timeframe, delta):
if timeframe == 'now':
return humanized[0]
direction = self.past if delta < 0 else self.future
which = 0 if delta < 0 else 1
return direction.format(humanized[which])
class ChineseCNLocale(Locale):
names = ['zh', 'zh_cn']
past = '{0}前'
future = '{0}后'
timeframes = {
'now': '刚才',
'seconds': '几秒',
'minute': '1分钟',
'minutes': '{0}分钟',
'hour': '1小时',
'hours': '{0}小时',
'day': '1天',
'days': '{0}天',
'month': '1个月',
'months': '{0}个月',
'year': '1年',
'years': '{0}年',
}
month_names = ['', '一月', '二月', '三月', '四月', '五月', '六月', '七月',
'八月', '九月', '十月', '十一月', '十二月']
month_abbreviations = ['', ' 1', ' 2', ' 3', ' 4', ' 5', ' 6', ' 7', ' 8',
' 9', '10', '11', '12']
day_names = ['', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
day_abbreviations = ['', '一', '二', '三', '四', '五', '六', '日']
class ChineseTWLocale(Locale):
names = ['zh_tw']
past = '{0}前'
future = '{0}後'
timeframes = {
'now': '剛才',
'seconds': '幾秒',
'minute': '1分鐘',
'minutes': '{0}分鐘',
'hour': '1小時',
'hours': '{0}小時',
'day': '1天',
'days': '{0}天',
'month': '1個月',
'months': '{0}個月',
'year': '1年',
'years': '{0}年',
}
month_names = ['', '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月',
'9月', '10月', '11月', '12月']
month_abbreviations = ['', ' 1', ' 2', ' 3', ' 4', ' 5', ' 6', ' 7', ' 8',
' 9', '10', '11', '12']
day_names = ['', '周一', '周二', '周三', '周四', '周五', '周六', '周日']
day_abbreviations = ['', '一', '二', '三', '四', '五', '六', '日']
class KoreanLocale(Locale):
names = ['ko', 'ko_kr']
past = '{0} 전'
future = '{0} 후'
timeframes = {
'now': '지금',
'seconds': '몇초',
'minute': '일 분',
'minutes': '{0}분',
'hour': '1시간',
'hours': '{0}시간',
'day': '1일',
'days': '{0}일',
'month': '1개월',
'months': '{0}개월',
'year': '1년',
'years': '{0}년',
}
month_names = ['', '1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월',
'9월', '10월', '11월', '12월']
month_abbreviations = ['', ' 1', ' 2', ' 3', ' 4', ' 5', ' 6', ' 7', ' 8',
' 9', '10', '11', '12']
day_names = ['', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일', '일요일']
day_abbreviations = ['', '월', '화', '수', '목', '금', '토', '일']
# derived locale types & implementations.
class DutchLocale(Locale):
names = ['nl', 'nl_nl']
past = '{0} geleden'
future = 'over {0}'
timeframes = {
'now': 'nu',
'seconds': 'seconden',
'minute': 'een minuut',
'minutes': '{0} minuten',
'hour': 'een uur',
'hours': '{0} uur',
'day': 'een dag',
'days': '{0} dagen',
'month': 'een maand',
'months': '{0} maanden',
'year': 'een jaar',
'years': '{0} jaar',
}
# In Dutch names of months and days are not starting with a capital letter
# like in the English language.
month_names = ['', 'januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli',
'augustus', 'september', 'oktober', 'november', 'december']
month_abbreviations = ['', 'jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug',
'sep', 'okt', 'nov', 'dec']
day_names = ['', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag', 'zondag']
day_abbreviations = ['', 'ma', 'di', 'wo', 'do', 'vr', 'za', 'zo']
class SlavicBaseLocale(Locale):
def _format_timeframe(self, timeframe, delta):
form = self.timeframes[timeframe]
delta = abs(delta)
if isinstance(form, list):
if delta % 10 == 1 and delta % 100 != 11:
form = form[0]
elif 2 <= delta % 10 <= 4 and (delta % 100 < 10 or delta % 100 >= 20):
form = form[1]
else:
form = form[2]
return form.format(delta)
class BelarusianLocale(SlavicBaseLocale):
names = ['be', 'be_by']
past = '{0} таму'
future = 'праз {0}'
timeframes = {
'now': 'зараз',
'seconds': 'некалькі секунд',
'minute': 'хвіліну',
'minutes': ['{0} хвіліну', '{0} хвіліны', '{0} хвілін'],
'hour': 'гадзіну',
'hours': ['{0} гадзіну', '{0} гадзіны', '{0} гадзін'],
'day': 'дзень',
'days': ['{0} дзень', '{0} дні', '{0} дзён'],
'month': 'месяц',
'months': ['{0} месяц', '{0} месяцы', '{0} месяцаў'],
'year': 'год',
'years': ['{0} год', '{0} гады', '{0} гадоў'],
}
month_names = ['', 'студзеня', 'лютага', 'сакавіка', 'красавіка', 'траўня', 'чэрвеня',
'ліпеня', 'жніўня', 'верасня', 'кастрычніка', 'лістапада', 'снежня']
month_abbreviations = ['', 'студ', 'лют', 'сак', 'крас', 'трав', 'чэрв', 'ліп', 'жнів',
'вер', 'каст', 'ліст', 'снеж']
day_names = ['', 'панядзелак', 'аўторак', 'серада', 'чацвер', 'пятніца', 'субота', 'нядзеля']
day_abbreviations = ['', 'пн', 'ат', 'ср', 'чц', 'пт', 'сб', 'нд']
class PolishLocale(SlavicBaseLocale):
names = ['pl', 'pl_pl']
past = '{0} temu'
future = 'za {0}'
timeframes = {
'now': 'teraz',
'seconds': 'kilka sekund',
'minute': 'minutę',
'minutes': ['{0} minut', '{0} minuty', '{0} minut'],
'hour': 'godzina',
'hours': ['{0} godzin', '{0} godziny', '{0} godzin'],
'day': 'dzień',
'days': ['{0} dzień', '{0} dni', '{0} dni'],
'month': 'miesiąc',
'months': ['{0} miesiąc', '{0} miesiące', '{0} miesięcy'],
'year': 'rok',
'years': ['{0} rok', '{0} lata', '{0} lat'],
}
month_names = ['', 'Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj',
'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik',
'Listopad', 'Grudzień']
month_abbreviations = ['', 'sty', 'lut', 'mar', 'kwi', 'maj', 'cze', 'lip',
'sie', 'wrz', 'paź', 'lis', 'gru']
day_names = ['', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek',
'Sobota', 'Niedziela']
day_abbreviations = ['', 'Pn', 'Wt', 'Śr', 'Czw', 'Pt', 'So', 'Nd']
class RussianLocale(SlavicBaseLocale):
names = ['ru', 'ru_ru']
past = '{0} назад'
future = 'через {0}'
timeframes = {
'now': 'сейчас',
'seconds': 'несколько секунд',
'minute': 'минуту',
'minutes': ['{0} минуту', '{0} минуты', '{0} минут'],
'hour': 'час',
'hours': ['{0} час', '{0} часа', '{0} часов'],
'day': 'день',
'days': ['{0} день', '{0} дня', '{0} дней'],
'month': 'месяц',
'months': ['{0} месяц', '{0} месяца', '{0} месяцев'],
'year': 'год',
'years': ['{0} год', '{0} года', '{0} лет'],
}
month_names = ['', 'января', 'февраля', 'марта', 'апреля', 'мая', 'июня',
'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря']
month_abbreviations = ['', 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл',
'авг', 'сен', 'окт', 'ноя', 'дек']
day_names = ['', 'понедельник', 'вторник', 'среда', 'четверг', 'пятница',
'суббота', 'воскресенье']
day_abbreviations = ['', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб', 'вс']
class UkrainianLocale(SlavicBaseLocale):
names = ['ua', 'uk_ua']
past = '{0} тому'
future = 'за {0}'
timeframes = {
'now': 'зараз',
'seconds': 'кілька секунд',
'minute': 'хвилину',
'minutes': ['{0} хвилину', '{0} хвилини', '{0} хвилин'],
'hour': 'годину',
'hours': ['{0} годину', '{0} години', '{0} годин'],
'day': 'день',
'days': ['{0} день', '{0} дні', '{0} днів'],
'month': 'місяць',
'months': ['{0} місяць', '{0} місяці', '{0} місяців'],
'year': 'рік',
'years': ['{0} рік', '{0} роки', '{0} років'],
}
month_names = ['', 'січня', 'лютого', 'березня', 'квітня', 'травня', 'червня',
'липня', 'серпня', 'вересня', 'жовтня', 'листопада', 'грудня']
month_abbreviations = ['', 'січ', 'лют', 'бер', 'квіт', 'трав', 'черв', 'лип', 'серп',
'вер', 'жовт', 'лист', 'груд']
day_names = ['', 'понеділок', 'вівторок', 'середа', 'четвер', 'п’ятниця', 'субота', 'неділя']
day_abbreviations = ['', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб', 'нд']
class GermanLocale(Locale):
names = ['de', 'de_de']
past = 'vor {0}'
future = 'in {0}'
timeframes = {
'now': 'gerade eben',
'seconds': 'Sekunden',
'minute': 'einer Minute',
'minutes': '{0} Minuten',
'hour': 'einer Stunde',
'hours': '{0} Stunden',
'day': 'einem Tag',
'days': '{0} Tagen',
'month': 'einem Monat',
'months': '{0} Monaten',
'year': 'einem Jahr',
'years': '{0} Jahren',
}
month_names = [
'', 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli',
'August', 'September', 'Oktober', 'November', 'Dezember'
]
month_abbreviations = [
'', 'Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep',
'Okt', 'Nov', 'Dez'
]
day_names = [
'', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag',
'Samstag', 'Sonntag'
]
day_abbreviations = ['', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']
class AustriaLocale(Locale):
names = ['de', 'de_at']
past = 'vor {0}'
future = 'in {0}'
timeframes = {
'now': 'gerade eben',
'seconds': 'Sekunden',
'minute': 'einer Minute',
'minutes': '{0} Minuten',
'hour': 'einer Stunde',
'hours': '{0} Stunden',
'day': 'einem Tag',
'days': '{0} Tage',
'month': 'einem Monat',
'months': '{0} Monaten',
'year': 'einem Jahr',
'years': '{0} Jahren',
}
month_names = [
'', 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli',
'August', 'September', 'Oktober', 'November', 'Dezember'
]
month_abbreviations = [
'', 'Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep',
'Okt', 'Nov', 'Dez'
]
day_names = [
'', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag',
'Samstag', 'Sonntag'
]
day_abbreviations = [
'', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'
]
class NorwegianLocale(Locale):
names = ['nb', 'nb_no']
past = 'for {0} siden'
future = 'om {0}'
timeframes = {
'now': 'nå nettopp',
'seconds': 'noen sekunder',
'minute': 'ett minutt',
'minutes': '{0} minutter',
'hour': 'en time',
'hours': '{0} timer',
'day': 'en dag',
'days': '{0} dager',
'month': 'en måned',
'months': '{0} måneder',
'year': 'ett år',
'years': '{0} år',
}
month_names = ['', 'januar', 'februar', 'mars', 'april', 'mai', 'juni',
'juli', 'august', 'september', 'oktober', 'november',
'desember']
month_abbreviations = ['', 'jan', 'feb', 'mar', 'apr', 'mai', 'jun', 'jul',
'aug', 'sep', 'okt', 'nov', 'des']
day_names = ['', 'mandag', 'tirsdag', 'onsdag', 'torsdag', 'fredag',
'lørdag', 'søndag']
day_abbreviations = ['', 'ma', 'ti', 'on', 'to', 'fr', 'lø', 'sø']
class NewNorwegianLocale(Locale):
names = ['nn', 'nn_no']
past = 'for {0} sidan'
future = 'om {0}'
timeframes = {
'now': 'no nettopp',
'seconds': 'nokre sekund',
'minute': 'ett minutt',
'minutes': '{0} minutt',
'hour': 'ein time',
'hours': '{0} timar',
'day': 'ein dag',
'days': '{0} dagar',
'month': 'en månad',
'months': '{0} månader',
'year': 'eit år',
'years': '{0} år',
}
month_names = ['', 'januar', 'februar', 'mars', 'april', 'mai', 'juni',
'juli', 'august', 'september', 'oktober', 'november',
'desember']
month_abbreviations = ['', 'jan', 'feb', 'mar', 'apr', 'mai', 'jun', 'jul',
'aug', 'sep', 'okt', 'nov', 'des']
day_names = ['', 'måndag', 'tysdag', 'onsdag', 'torsdag', 'fredag',
'laurdag', 'sundag']
day_abbreviations = ['', 'må', 'ty', 'on', 'to', 'fr', 'la', 'su']
class PortugueseLocale(Locale):
names = ['pt', 'pt_pt']
past = 'há {0}'
future = 'em {0}'
timeframes = {
'now': 'agora',
'seconds': 'segundos',
'minute': 'um minuto',
'minutes': '{0} minutos',
'hour': 'uma hora',
'hours': '{0} horas',
'day': 'um dia',
'days': '{0} dias',
'month': 'um mês',
'months': '{0} meses',
'year': 'um ano',
'years': '{0} anos',
}
month_names = ['', 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho',
'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']
month_abbreviations = ['', 'Jan', 'Fev', 'Mar', 'Abr', 'Maio', 'Jun', 'Jul', 'Ago',
'Set', 'Out', 'Nov', 'Dez']
day_names = ['', 'Segunda-feira', 'Terça-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira',
'Sábado', 'Domingo']
day_abbreviations = ['', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab', 'Dom']
class BrazilianPortugueseLocale(PortugueseLocale):
names = ['pt_br']
past = 'fazem {0}'
class TagalogLocale(Locale):
names = ['tl']
past = 'nakaraang {0}'
future = '{0} mula ngayon'
timeframes = {
'now': 'ngayon lang',
'seconds': 'segundo',
'minute': 'isang minuto',
'minutes': '{0} minuto',
'hour': 'isang oras',
'hours': '{0} oras',
'day': 'isang araw',
'days': '{0} araw',
'month': 'isang buwan',
'months': '{0} buwan',
'year': 'isang taon',
'years': '{0} taon',
}
month_names = ['', 'Enero', 'Pebrero', 'Marso', 'Abril', 'Mayo', 'Hunyo', 'Hulyo',
'Agosto', 'Setyembre', 'Oktubre', 'Nobyembre', 'Disyembre']
month_abbreviations = ['', 'Ene', 'Peb', 'Mar', 'Abr', 'May', 'Hun', 'Hul', 'Ago',
'Set', 'Okt', 'Nob', 'Dis']
day_names = ['', 'Lunes', 'Martes', 'Miyerkules', 'Huwebes', 'Biyernes', 'Sabado', 'Linggo']
day_abbreviations = ['', 'Lun', 'Mar', 'Miy', 'Huw', 'Biy', 'Sab', 'Lin']
class VietnameseLocale(Locale):
names = ['vi', 'vi_vn']
past = '{0} trước'
future = '{0} nữa'
timeframes = {
'now': 'hiện tại',
'seconds': 'giây',
'minute': 'một phút',
'minutes': '{0} phút',
'hour': 'một giờ',
'hours': '{0} giờ',
'day': 'một ngày',
'days': '{0} ngày',
'month': 'một tháng',
'months': '{0} tháng',
'year': 'một năm',
'years': '{0} năm',
}
month_names = ['', 'Tháng Một', 'Tháng Hai', 'Tháng Ba', 'Tháng Tư', 'Tháng Năm', 'Tháng Sáu', 'Tháng Bảy',
'Tháng Tám', 'Tháng Chín', 'Tháng Mười', 'Tháng Mười Một', 'Tháng Mười Hai']
month_abbreviations = ['', 'Tháng 1', 'Tháng 2', 'Tháng 3', 'Tháng 4', 'Tháng 5', 'Tháng 6', 'Tháng 7', 'Tháng 8',
'Tháng 9', 'Tháng 10', 'Tháng 11', 'Tháng 12']
day_names = ['', 'Thứ Hai', 'Thứ Ba', 'Thứ Tư', 'Thứ Năm', 'Thứ Sáu', 'Thứ Bảy', 'Chủ Nhật']
day_abbreviations = ['', 'Thứ 2', 'Thứ 3', 'Thứ 4', 'Thứ 5', 'Thứ 6', 'Thứ 7', 'CN']
class TurkishLocale(Locale):
names = ['tr', 'tr_tr']
past = '{0} önce'
future = '{0} sonra'
timeframes = {
'now': 'şimdi',
'seconds': 'saniye',
'minute': 'bir dakika',
'minutes': '{0} dakika',
'hour': 'bir saat',
'hours': '{0} saat',
'day': 'bir gün',
'days': '{0} gün',
'month': 'bir ay',
'months': '{0} ay',
'year': 'a yıl',
'years': '{0} yıl',
}
month_names = ['', 'Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz',
'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık']
month_abbreviations = ['', 'Oca', 'Şub', 'Mar', 'Nis', 'May', 'Haz', 'Tem', 'Ağu',
'Eyl', 'Eki', 'Kas', 'Ara']
day_names = ['', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi', 'Pazar']
day_abbreviations = ['', 'Pzt', 'Sal', 'Çar', 'Per', 'Cum', 'Cmt', 'Paz']
class ArabicLocale(Locale):
names = ['ar', 'ar_eg']
past = 'منذ {0}'
future = 'خلال {0}'
timeframes = {
'now': 'الآن',
'seconds': 'ثوان',
'minute': 'دقيقة',
'minutes': '{0} دقائق',
'hour': 'ساعة',
'hours': '{0} ساعات',
'day': 'يوم',
'days': '{0} أيام',
'month': 'شهر',
'months': '{0} شهور',
'year': 'سنة',
'years': '{0} سنوات',
}
month_names = ['', 'يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو',
'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر']
month_abbreviations = ['', 'يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو',
'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر']
day_names = ['', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت', 'الأحد']
day_abbreviations = ['', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت', 'أحد']
class IcelandicLocale(Locale):
def _format_timeframe(self, timeframe, delta):
timeframe = self.timeframes[timeframe]
if delta < 0:
timeframe = timeframe[0]
elif delta > 0:
timeframe = timeframe[1]
return timeframe.format(abs(delta))
names = ['is', 'is_is']
past = 'fyrir {0} síðan'
future = 'eftir {0}'
timeframes = {
'now': 'rétt í þessu',
'seconds': ('nokkrum sekúndum', 'nokkrar sekúndur'),
'minute': ('einni mínútu', 'eina mínútu'),
'minutes': ('{0} mínútum', '{0} mínútur'),
'hour': ('einum tíma', 'einn tíma'),
'hours': ('{0} tímum', '{0} tíma'),
'day': ('einum degi', 'einn dag'),
'days': ('{0} dögum', '{0} daga'),
'month': ('einum mánuði', 'einn mánuð'),
'months': ('{0} mánuðum', '{0} mánuði'),
'year': ('einu ári', 'eitt ár'),
'years': ('{0} árum', '{0} ár'),
}
meridians = {
'am': 'f.h.',
'pm': 'e.h.',
'AM': 'f.h.',
'PM': 'e.h.',
}
month_names = ['', 'janúar', 'febrúar', 'mars', 'apríl', 'maí', 'júní',
'júlí', 'ágúst', 'september', 'október', 'nóvember', 'desember']
month_abbreviations = ['', 'jan', 'feb', 'mar', 'apr', 'maí', 'jún',
'júl', 'ágú', 'sep', 'okt', 'nóv', 'des']
day_names = ['', 'mánudagur', 'þriðjudagur', 'miðvikudagur', 'fimmtudagur',
'föstudagur', 'laugardagur', 'sunnudagur']
day_abbreviations = ['', 'mán', 'þri', 'mið', 'fim', 'fös', 'lau', 'sun']
class DanishLocale(Locale):
names = ['da', 'da_dk']
past = 'for {0} siden'
future = 'efter {0}'
timeframes = {
'now': 'lige nu',
'seconds': 'et par sekunder',
'minute': 'et minut',
'minutes': '{0} minutter',
'hour': 'en time',
'hours': '{0} timer',
'day': 'en dag',
'days': '{0} dage',
'month': 'en måned',
'months': '{0} måneder',
'year': 'et år',
'years': '{0} år',
}
month_names = ['', 'januar', 'februar', 'marts', 'april', 'maj', 'juni',
'juli', 'august', 'september', 'oktober', 'november', 'december']
month_abbreviations = ['', 'jan', 'feb', 'mar', 'apr', 'maj', 'jun',
'jul', 'aug', 'sep', 'okt', 'nov', 'dec']
day_names = ['', 'mandag', 'tirsdag', 'onsdag', 'torsdag', 'fredag',
'lørdag', 'søndag']
day_abbreviations = ['', 'man', 'tir', 'ons', 'tor', 'fre', 'lør', 'søn']
class MalayalamLocale(Locale):
names = ['ml']
past = '{0} മുമ്പ്'
future = '{0} ശേഷം'
timeframes = {
'now': 'ഇപ്പോൾ',
'seconds': 'സെക്കന്റ്',
'minute': 'ഒരു മിനിറ്റ്',
'minutes': '{0} മിനിറ്റ്',
'hour': 'ഒരു മണിക്കൂർ',
'hours': '{0} മണിക്കൂർ',
'day': 'ഒരു ദിവസം ',
'days': '{0} ദിവസം ',
'month': 'ഒരു മാസം ',
'months': '{0} മാസം ',
'year': 'ഒരു വർഷം ',
'years': '{0} വർഷം ',
}
meridians = {
'am': 'രാവിലെ',
'pm': 'ഉച്ചക്ക് ശേഷം',
'AM': 'രാവിലെ',
'PM': 'ഉച്ചക്ക് ശേഷം',
}
month_names = ['', 'ജനുവരി', 'ഫെബ്രുവരി', 'മാർച്ച്', 'ഏപ്രിൽ ', 'മെയ് ', 'ജൂണ്', 'ജൂലൈ',
'ഓഗസ്റ്റ്', 'സെപ്റ്റംബർ', 'ഒക്ടോബർ', 'നവംബർ', 'ഡിസംബർ']
month_abbreviations = ['', 'ജനു', 'ഫെബ് ', 'മാർ', 'ഏപ്രിൽ', 'മേയ്', 'ജൂണ്', 'ജൂലൈ', 'ഓഗസ്റ',
'സെപ്റ്റ', 'ഒക്ടോ', 'നവം', 'ഡിസം']
day_names = ['', 'തിങ്കള്', 'ചൊവ്വ', 'ബുധന്', 'വ്യാഴം', 'വെള്ളി', 'ശനി', 'ഞായര്']
day_abbreviations = ['', 'തിങ്കള്', 'ചൊവ്വ', 'ബുധന്', 'വ്യാഴം', 'വെള്ളി', 'ശനി', 'ഞായര്']
class HindiLocale(Locale):
names = ['hi']
past = '{0} पहले'
future = '{0} बाद'
timeframes = {
'now': 'अभि',
'seconds': 'सेकंड्',
'minute': 'एक मिनट ',
'minutes': '{0} मिनट ',
'hour': 'एक घंट',
'hours': '{0} घंटे',
'day': 'एक दिन',
'days': '{0} दिन',
'month': 'एक माह ',
'months': '{0} महीने ',
'year': 'एक वर्ष ',
'years': '{0} साल ',
}
meridians = {
'am': 'सुबह',
'pm': 'शाम',
'AM': 'सुबह',
'PM': 'शाम',
}
month_names = ['', 'जनवरी', 'फ़रवरी', 'मार्च', 'अप्रैल ', 'मई', 'जून', 'जुलाई',
'आगस्त', 'सितम्बर', 'अकतूबर', 'नवेम्बर', 'दिसम्बर']
month_abbreviations = ['', 'जन', 'फ़र', 'मार्च', 'अप्रै', 'मई', 'जून', 'जुलाई', 'आग',
'सित', 'अकत', 'नवे', 'दिस']
day_names = ['', 'सोमवार', 'मंगलवार', 'बुधवार', 'गुरुवार', 'शुक्रवार', 'शनिवार', 'रविवार']
day_abbreviations = ['', 'सोम', 'मंगल', 'बुध', 'गुरुवार', 'शुक्र', 'शनि', 'रवि']
class CzechLocale(Locale):
names = ['cs', 'cs_cz']
timeframes = {
'now': 'Teď',
'seconds': {
'past': '{0} sekundami',
'future': ['{0} sekundy', '{0} sekund']
},
'minute': {'past': 'minutou', 'future': 'minutu', 'zero': '{0} minut'},
'minutes': {
'past': '{0} minutami',
'future': ['{0} minuty', '{0} minut']
},
'hour': {'past': 'hodinou', 'future': 'hodinu', 'zero': '{0} hodin'},
'hours': {
'past': '{0} hodinami',
'future': ['{0} hodiny', '{0} hodin']
},
'day': {'past': 'dnem', 'future': 'den', 'zero': '{0} dnů'},
'days': {
'past': '{0} dny',
'future': ['{0} dny', '{0} dnů']
},
'month': {'past': 'měsícem', 'future': 'měsíc', 'zero': '{0} měsíců'},
'months': {
'past': '{0} měsíci',
'future': ['{0} měsíce', '{0} měsíců']
},
'year': {'past': 'rokem', 'future': 'rok', 'zero': '{0} let'},
'years': {
'past': '{0} lety',
'future': ['{0} roky', '{0} let']
}
}
past = 'Před {0}'
future = 'Za {0}'
month_names = ['', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen',
'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec']
month_abbreviations = ['', 'Led', 'Úno', 'Bře', 'Dub', 'Kvě', 'Čvn', 'Čvc',
'Srp', 'Zář', 'Říj', 'Lis', 'Pro']
day_names = ['', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek',
'Sobota', 'Neděle']
day_abbreviations = ['', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So', 'Ne']
def _format_timeframe(self, timeframe, delta):
'''Czech aware time frame format function, takes into account the differences between past and future forms.'''
form = self.timeframes[timeframe]
if isinstance(form, dict):
if delta == 0:
form = form['zero'] # And *never* use 0 in the singular!
elif delta > 0:
form = form['future']
else:
form = form['past']
delta = abs(delta)
if isinstance(form, list):
if 2 <= delta % 10 <= 4 and (delta % 100 < 10 or delta % 100 >= 20):
form = form[0]
else:
form = form[1]
return form.format(delta)
class FarsiLocale(Locale):
names = ['fa', 'fa_ir']
past = '{0} قبل'
future = 'در {0}'
timeframes = {
'now': 'اکنون',
'seconds': 'ثانیه',
'minute': 'یک دقیقه',
'minutes': '{0} دقیقه',
'hour': 'یک ساعت',
'hours': '{0} ساعت',
'day': 'یک روز',
'days': '{0} روز',
'month': 'یک ماه',
'months': '{0} ماه',
'year': 'یک سال',
'years': '{0} سال',
}
meridians = {
'am': 'قبل از ظهر',
'pm': 'بعد از ظهر',
'AM': 'قبل از ظهر',
'PM': 'بعد از ظهر',
}
month_names = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
month_abbreviations = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec']
day_names = ['', 'دو شنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه', 'یکشنبه']
day_abbreviations = ['', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
class MacedonianLocale(Locale):
names = ['mk', 'mk_mk']
past = 'пред {0}'
future = 'за {0}'
timeframes = {
'now': 'сега',
'seconds': 'секунди',
'minute': 'една минута',
'minutes': '{0} минути',
'hour': 'еден саат',
'hours': '{0} саати',
'day': 'еден ден',
'days': '{0} дена',
'month': 'еден месец',
'months': '{0} месеци',
'year': 'една година',
'years': '{0} години',
}
meridians = {
'am': 'дп',
'pm': 'пп',
'AM': 'претпладне',
'PM': 'попладне',
}
month_names = ['', 'Јануари', 'Февруари', 'Март', 'Април', 'Мај', 'Јуни', 'Јули', 'Август', 'Септември', 'Октомври',
'Ноември', 'Декември']
month_abbreviations = ['', 'Јан.', ' Фев.', ' Мар.', ' Апр.', ' Мај', ' Јун.', ' Јул.', ' Авг.', ' Септ.', ' Окт.',
' Ноем.', ' Декем.']
day_names = ['', 'Понеделник', ' Вторник', ' Среда', ' Четврток', ' Петок', ' Сабота', ' Недела']
day_abbreviations = ['', 'Пон.', ' Вт.', ' Сре.', ' Чет.', ' Пет.', ' Саб.', ' Нед.']
class HebrewLocale(Locale):
names = ['he', 'he_IL']
past = 'לפני {0}'
future = 'בעוד {0}'
timeframes = {
'now': 'הרגע',
'seconds': 'שניות',
'minute': 'דקה',
'minutes': '{0} דקות',
'hour': 'שעה',
'hours': '{0} שעות',
'2-hours': 'שעתיים',
'day': 'יום',
'days': '{0} ימים',
'2-days': 'יומיים',
'month': 'חודש',
'months': '{0} חודשים',
'2-months': 'חודשיים',
'year': 'שנה',
'years': '{0} שנים',
'2-years': 'שנתיים',
}
meridians = {
'am': 'לפנ"צ',
'pm': 'אחר"צ',
'AM': 'לפני הצהריים',
'PM': 'אחרי הצהריים',
}
month_names = ['', 'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי',
'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר']
month_abbreviations = ['', 'ינו׳', 'פבר׳', 'מרץ', 'אפר׳', 'מאי', 'יוני', 'יולי', 'אוג׳',
'ספט׳', 'אוק׳', 'נוב׳', 'דצמ׳']
day_names = ['', 'שני', 'שלישי', 'רביעי', 'חמישי', 'שישי', 'שבת', 'ראשון']
day_abbreviations = ['', 'ב׳', 'ג׳', 'ד׳', 'ה׳', 'ו׳', 'ש׳', 'א׳']
def _format_timeframe(self, timeframe, delta):
'''Hebrew couple of aware'''
couple = '2-{0}'.format(timeframe)
if abs(delta) == 2 and couple in self.timeframes:
return self.timeframes[couple].format(abs(delta))
else:
return self.timeframes[timeframe].format(abs(delta))
class MarathiLocale(Locale):
names = ['mr']
past = '{0} आधी'
future = '{0} नंतर'
timeframes = {
'now': 'सद्य',
'seconds': 'सेकंद',
'minute': 'एक मिनिट ',
'minutes': '{0} मिनिट ',
'hour': 'एक तास',
'hours': '{0} तास',
'day': 'एक दिवस',
'days': '{0} दिवस',
'month': 'एक महिना ',
'months': '{0} महिने ',
'year': 'एक वर्ष ',
'years': '{0} वर्ष ',
}
meridians = {
'am': 'सकाळ',
'pm': 'संध्याकाळ',
'AM': 'सकाळ',
'PM': 'संध्याकाळ',
}
month_names = ['', 'जानेवारी', 'फेब्रुवारी', 'मार्च', 'एप्रिल', 'मे', 'जून', 'जुलै',
'अॉगस्ट', 'सप्टेंबर', 'अॉक्टोबर', 'नोव्हेंबर', 'डिसेंबर']
month_abbreviations = ['', 'जान', 'फेब्रु', 'मार्च', 'एप्रि', 'मे', 'जून', 'जुलै', 'अॉग',
'सप्टें', 'अॉक्टो', 'नोव्हें', 'डिसें']
day_names = ['', 'सोमवार', 'मंगळवार', 'बुधवार', 'गुरुवार', 'शुक्रवार', 'शनिवार', 'रविवार']
day_abbreviations = ['', 'सोम', 'मंगळ', 'बुध', 'गुरु', 'शुक्र', 'शनि', 'रवि']
def _map_locales():
locales = {}
for cls_name, cls in inspect.getmembers(sys.modules[__name__], inspect.isclass):
if issubclass(cls, Locale):
for name in cls.names:
locales[name.lower()] = cls
return locales
class CatalaLocale(Locale):
names = ['ca', 'ca_ca']
past = 'Fa {0}'
future = '{0}' # I don't know what's the right phrase in catala for the future.
timeframes = {
'now': 'Ara mateix',
'seconds': 'segons',
'minute': '1 minut',
'minutes': '{0} minuts',
'hour': 'una hora',
'hours': '{0} hores',
'day': 'un dia',
'days': '{0} dies',
'month': 'un mes',
'months': '{0} messos',
'year': 'un any',
'years': '{0} anys',
}
month_names = ['', 'Jener', 'Febrer', 'Març', 'Abril', 'Maig', 'Juny', 'Juliol', 'Agost', 'Setembre', 'Octubre', 'Novembre', 'Decembre']
month_abbreviations = ['', 'Jener', 'Febrer', 'Març', 'Abril', 'Maig', 'Juny', 'Juliol', 'Agost', 'Setembre', 'Octubre', 'Novembre', 'Decembre']
day_names = ['', 'Dilluns', 'Dimars', 'Dimecres', 'Dijous', 'Divendres', 'Disabte', 'Diumenge']
day_abbreviations = ['', 'Dilluns', 'Dimars', 'Dimecres', 'Dijous', 'Divendres', 'Disabte', 'Diumenge']
class BasqueLocale(Locale):
names = ['eu', 'eu_eu']
past = 'duela {0}'
future = '{0}' # I don't know what's the right phrase in Basque for the future.
timeframes = {
'now': 'Orain',
'seconds': 'segundu',
'minute': 'minutu bat',
'minutes': '{0} minutu',
'hour': 'ordu bat',
'hours': '{0} ordu',
'day': 'egun bat',
'days': '{0} egun',
'month': 'hilabete bat',
'months': '{0} hilabet',
'year': 'urte bat',
'years': '{0} urte',
}
month_names = ['', 'Urtarrilak', 'Otsailak', 'Martxoak', 'Apirilak', 'Maiatzak', 'Ekainak', 'Uztailak', 'Abuztuak', 'Irailak', 'Urriak', 'Azaroak', 'Abenduak']
month_abbreviations = ['', 'urt', 'ots', 'mar', 'api', 'mai', 'eka', 'uzt', 'abu', 'ira', 'urr', 'aza', 'abe']
day_names = ['', 'Asteleehna', 'Asteartea', 'Asteazkena', 'Osteguna', 'Ostirala', 'Larunbata', 'Igandea']
day_abbreviations = ['', 'al', 'ar', 'az', 'og', 'ol', 'lr', 'ig']
class HungarianLocale(Locale):
names = ['hu', 'hu_hu']
past = '{0} ezelőtt'
future = '{0} múlva'
timeframes = {
'now': 'éppen most',
'seconds': {
'past': 'másodpercekkel',
'future': 'pár másodperc'
},
'minute': {'past': 'egy perccel', 'future': 'egy perc'},
'minutes': {'past': '{0} perccel', 'future': '{0} perc'},
'hour': {'past': 'egy órával', 'future': 'egy óra'},
'hours': {'past': '{0} órával', 'future': '{0} óra'},
'day': {
'past': 'egy nappal',
'future': 'egy nap'
},
'days': {
'past': '{0} nappal',
'future': '{0} nap'
},
'month': {'past': 'egy hónappal', 'future': 'egy hónap'},
'months': {'past': '{0} hónappal', 'future': '{0} hónap'},
'year': {'past': 'egy évvel', 'future': 'egy év'},
'years': {'past': '{0} évvel', 'future': '{0} év'},
}
month_names = ['', 'Január', 'Február', 'Március', 'Április', 'Május',
'Június', 'Július', 'Augusztus', 'Szeptember',
'Október', 'November', 'December']
month_abbreviations = ['', 'Jan', 'Febr', 'Márc', 'Ápr', 'Máj', 'Jún',
'Júl', 'Aug', 'Szept', 'Okt', 'Nov', 'Dec']
day_names = ['', 'Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek',
'Szombat', 'Vasárnap']
day_abbreviations = ['', 'Hét', 'Kedd', 'Szer', 'Csüt', 'Pént',
'Szom', 'Vas']
meridians = {
'am': 'de',
'pm': 'du',
'AM': 'DE',
'PM': 'DU',
}
def _format_timeframe(self, timeframe, delta):
form = self.timeframes[timeframe]
if isinstance(form, dict):
if delta > 0:
form = form['future']
else:
form = form['past']
return form.format(abs(delta))
class ThaiLocale(Locale):
names = ['th', 'th_th']
past = '{0}{1}ที่ผ่านมา'
future = 'ในอีก{1}{0}'
timeframes = {
'now': 'ขณะนี้',
'seconds': 'ไม่กี่วินาที',
'minute': '1 นาที',
'minutes': '{0} นาที',
'hour': '1 ชั่วโมง',
'hours': '{0} ชั่วโมง',
'day': '1 วัน',
'days': '{0} วัน',
'month': '1 เดือน',
'months': '{0} เดือน',
'year': '1 ปี',
'years': '{0} ปี',
}
month_names = ['', 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน',
'พฤษภาคม', 'มิถุนายน', 'กรกฏาคม', 'สิงหาคม',
'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม']
month_abbreviations = ['', 'ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.',
'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.',
'พ.ย.', 'ธ.ค.']
day_names = ['', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์',
'เสาร์', 'อาทิตย์']
day_abbreviations = ['', 'จ', 'อ', 'พ', 'พฤ', 'ศ', 'ส', 'อา']
meridians = {
'am': 'am',
'pm': 'pm',
'AM': 'AM',
'PM': 'PM',
}
BE_OFFSET = 543
def year_full(self, year):
'''Thai always use Buddhist Era (BE) which is CE + 543'''
year += self.BE_OFFSET
return '{0:04d}'.format(year)
def year_abbreviation(self, year):
'''Thai always use Buddhist Era (BE) which is CE + 543'''
year += self.BE_OFFSET
return '{0:04d}'.format(year)[2:]
def _format_relative(self, humanized, timeframe, delta):
'''Thai normally doesn't have any space between words'''
if timeframe == 'now':
return humanized
space = '' if timeframe == 'seconds' else ' '
direction = self.past if delta < 0 else self.future
return direction.format(humanized, space)
_locales = _map_locales()
arrow-0.7.0/arrow/parser.py 0000664 0000000 0000000 00000022602 12605232351 0015651 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
from datetime import datetime
from dateutil import tz
import re
from arrow import locales
class ParserError(RuntimeError):
pass
class DateTimeParser(object):
_FORMAT_RE = re.compile('(YYY?Y?|MM?M?M?|Do|DD?D?D?|HH?|hh?|mm?|ss?|SS?S?S?S?S?|ZZ?|a|A|X)')
_ONE_THROUGH_SIX_DIGIT_RE = re.compile('\d{1,6}')
_ONE_THROUGH_FIVE_DIGIT_RE = re.compile('\d{1,5}')
_ONE_THROUGH_FOUR_DIGIT_RE = re.compile('\d{1,4}')
_ONE_TWO_OR_THREE_DIGIT_RE = re.compile('\d{1,3}')
_ONE_OR_TWO_DIGIT_RE = re.compile('\d{1,2}')
_FOUR_DIGIT_RE = re.compile('\d{4}')
_TWO_DIGIT_RE = re.compile('\d{2}')
_TZ_RE = re.compile('[+\-]?\d{2}:?\d{2}')
_BASE_INPUT_RE_MAP = {
'YYYY': _FOUR_DIGIT_RE,
'YY': _TWO_DIGIT_RE,
'MM': _TWO_DIGIT_RE,
'M': _ONE_OR_TWO_DIGIT_RE,
'DD': _TWO_DIGIT_RE,
'D': _ONE_OR_TWO_DIGIT_RE,
'HH': _TWO_DIGIT_RE,
'H': _ONE_OR_TWO_DIGIT_RE,
'hh': _TWO_DIGIT_RE,
'h': _ONE_OR_TWO_DIGIT_RE,
'mm': _TWO_DIGIT_RE,
'm': _ONE_OR_TWO_DIGIT_RE,
'ss': _TWO_DIGIT_RE,
's': _ONE_OR_TWO_DIGIT_RE,
'X': re.compile('\d+'),
'ZZ': _TZ_RE,
'Z': _TZ_RE,
'SSSSSS': _ONE_THROUGH_SIX_DIGIT_RE,
'SSSSS': _ONE_THROUGH_FIVE_DIGIT_RE,
'SSSS': _ONE_THROUGH_FOUR_DIGIT_RE,
'SSS': _ONE_TWO_OR_THREE_DIGIT_RE,
'SS': _ONE_OR_TWO_DIGIT_RE,
'S': re.compile('\d'),
}
def __init__(self, locale='en_us'):
self.locale = locales.get_locale(locale)
self._input_re_map = self._BASE_INPUT_RE_MAP.copy()
self._input_re_map.update({
'MMMM': self._choice_re(self.locale.month_names[1:], re.IGNORECASE),
'MMM': self._choice_re(self.locale.month_abbreviations[1:],
re.IGNORECASE),
'Do': re.compile(self.locale.ordinal_day_re),
'a': self._choice_re(
(self.locale.meridians['am'], self.locale.meridians['pm'])
),
# note: 'A' token accepts both 'am/pm' and 'AM/PM' formats to
# ensure backwards compatibility of this token
'A': self._choice_re(self.locale.meridians.values())
})
def parse_iso(self, string):
has_time = 'T' in string or ' ' in string.strip()
space_divider = ' ' in string.strip()
if has_time:
if space_divider:
date_string, time_string = string.split(' ', 1)
else:
date_string, time_string = string.split('T', 1)
time_parts = re.split('[+-]', time_string, 1)
has_tz = len(time_parts) > 1
has_seconds = time_parts[0].count(':') > 1
has_subseconds = '.' in time_parts[0]
if has_subseconds:
subseconds_token = 'S' * min(len(re.split('\D+', time_parts[0].split('.')[1], 1)[0]), 6)
formats = ['YYYY-MM-DDTHH:mm:ss.%s' % subseconds_token]
elif has_seconds:
formats = ['YYYY-MM-DDTHH:mm:ss']
else:
formats = ['YYYY-MM-DDTHH:mm']
else:
has_tz = False
formats = [
'YYYY-MM-DD',
'YYYY-MM',
'YYYY',
]
if has_time and has_tz:
formats = [f + 'Z' for f in formats]
if space_divider:
formats = [item.replace('T', ' ', 1) for item in formats]
return self._parse_multiformat(string, formats)
def parse(self, string, fmt):
if isinstance(fmt, list):
return self._parse_multiformat(string, fmt)
# fmt is a string of tokens like 'YYYY-MM-DD'
# we construct a new string by replacing each
# token by its pattern:
# 'YYYY-MM-DD' -> '(?P\d{4})-(?P\d{2})-(?P
\d{2})'
fmt_pattern = fmt
tokens = []
offset = 0
for m in self._FORMAT_RE.finditer(fmt):
token = m.group(0)
try:
input_re = self._input_re_map[token]
except KeyError:
raise ParserError('Unrecognized token \'{0}\''.format(token))
input_pattern = '(?P<{0}>{1})'.format(token, input_re.pattern)
tokens.append(token)
# a pattern doesn't have the same length as the token
# it replaces! We keep the difference in the offset variable.
# This works because the string is scanned left-to-right and matches
# are returned in the order found by finditer.
fmt_pattern = fmt_pattern[:m.start() + offset] + input_pattern + fmt_pattern[m.end() + offset:]
offset += len(input_pattern) - (m.end() - m.start())
match = re.search(fmt_pattern, string, flags=re.IGNORECASE)
if match is None:
raise ParserError('Failed to match \'{0}\' when parsing \'{1}\''.format(fmt_pattern, string))
parts = {}
for token in tokens:
if token == 'Do':
value = match.group('value')
else:
value = match.group(token)
self._parse_token(token, value, parts)
return self._build_datetime(parts)
def _parse_token(self, token, value, parts):
if token == 'YYYY':
parts['year'] = int(value)
elif token == 'YY':
value = int(value)
parts['year'] = 1900 + value if value > 68 else 2000 + value
elif token in ['MMMM', 'MMM']:
parts['month'] = self.locale.month_number(value.capitalize())
elif token in ['MM', 'M']:
parts['month'] = int(value)
elif token in ['DD', 'D']:
parts['day'] = int(value)
elif token in ['Do']:
parts['day'] = int(value)
elif token.upper() in ['HH', 'H']:
parts['hour'] = int(value)
elif token in ['mm', 'm']:
parts['minute'] = int(value)
elif token in ['ss', 's']:
parts['second'] = int(value)
elif token == 'SSSSSS':
parts['microsecond'] = int(value)
elif token == 'SSSSS':
parts['microsecond'] = int(value) * 10
elif token == 'SSSS':
parts['microsecond'] = int(value) * 100
elif token == 'SSS':
parts['microsecond'] = int(value) * 1000
elif token == 'SS':
parts['microsecond'] = int(value) * 10000
elif token == 'S':
parts['microsecond'] = int(value) * 100000
elif token == 'X':
parts['timestamp'] = int(value)
elif token in ['ZZ', 'Z']:
parts['tzinfo'] = TzinfoParser.parse(value)
elif token in ['a', 'A']:
if value in (
self.locale.meridians['am'],
self.locale.meridians['AM']
):
parts['am_pm'] = 'am'
elif value in (
self.locale.meridians['pm'],
self.locale.meridians['PM']
):
parts['am_pm'] = 'pm'
@staticmethod
def _build_datetime(parts):
timestamp = parts.get('timestamp')
if timestamp:
tz_utc = tz.tzutc()
return datetime.fromtimestamp(timestamp, tz=tz_utc)
am_pm = parts.get('am_pm')
hour = parts.get('hour', 0)
if am_pm == 'pm' and hour < 12:
hour += 12
elif am_pm == 'am' and hour == 12:
hour = 0
return datetime(year=parts.get('year', 1), month=parts.get('month', 1),
day=parts.get('day', 1), hour=hour, minute=parts.get('minute', 0),
second=parts.get('second', 0), microsecond=parts.get('microsecond', 0),
tzinfo=parts.get('tzinfo'))
def _parse_multiformat(self, string, formats):
_datetime = None
for fmt in formats:
try:
_datetime = self.parse(string, fmt)
break
except:
pass
if _datetime is None:
raise ParserError('Could not match input to any of {0} on \'{1}\''.format(formats, string))
return _datetime
@staticmethod
def _map_lookup(input_map, key):
try:
return input_map[key]
except KeyError:
raise ParserError('Could not match "{0}" to {1}'.format(key, input_map))
@staticmethod
def _try_timestamp(string):
try:
return float(string)
except:
return None
@staticmethod
def _choice_re(choices, flags=0):
return re.compile('({0})'.format('|'.join(choices)), flags=flags)
class TzinfoParser(object):
_TZINFO_RE = re.compile('([+\-])?(\d\d):?(\d\d)')
@classmethod
def parse(cls, string):
tzinfo = None
if string == 'local':
tzinfo = tz.tzlocal()
elif string in ['utc', 'UTC']:
tzinfo = tz.tzutc()
else:
iso_match = cls._TZINFO_RE.match(string)
if iso_match:
sign, hours, minutes = iso_match.groups()
seconds = int(hours) * 3600 + int(minutes) * 60
if sign == '-':
seconds *= -1
tzinfo = tz.tzoffset(None, seconds)
else:
tzinfo = tz.gettz(string)
if tzinfo is None:
raise ParserError('Could not parse timezone expression "{0}"', string)
return tzinfo
arrow-0.7.0/arrow/util.py 0000664 0000000 0000000 00000001770 12605232351 0015335 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
from __future__ import absolute_import
from datetime import timedelta
import sys
# python 2.6 / 2.7 definitions for total_seconds function.
def _total_seconds_27(td): # pragma: no cover
return td.total_seconds()
def _total_seconds_26(td):
return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 1e6) / 1e6
# get version info and assign correct total_seconds function.
version = '{0}.{1}.{2}'.format(*sys.version_info[:3])
if version < '2.7': # pragma: no cover
total_seconds = _total_seconds_26
else: # pragma: no cover
total_seconds = _total_seconds_27
def is_timestamp(value):
try:
float(value)
return True
except:
return False
# python 2.7 / 3.0+ definitions for isstr function.
try: # pragma: no cover
basestring
def isstr(s):
return isinstance(s, basestring)
except NameError: #pragma: no cover
def isstr(s):
return isinstance(s, str)
__all__ = ['total_seconds', 'is_timestamp', 'isstr']
arrow-0.7.0/docs/ 0000775 0000000 0000000 00000000000 12605232351 0013577 5 ustar 00root root 0000000 0000000 arrow-0.7.0/docs/Makefile 0000664 0000000 0000000 00000015146 12605232351 0015246 0 ustar 00root root 0000000 0000000 # Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make ' where is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Arrow.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Arrow.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/Arrow"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Arrow"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
arrow-0.7.0/docs/_themes/ 0000775 0000000 0000000 00000000000 12605232351 0015223 5 ustar 00root root 0000000 0000000 arrow-0.7.0/docs/_themes/COPYING.txt 0000664 0000000 0000000 00000001214 12605232351 0017072 0 ustar 00root root 0000000 0000000 Copyright (c) 2011 Vimalkumar Velayudhan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
arrow-0.7.0/docs/_themes/README.rst 0000664 0000000 0000000 00000001725 12605232351 0016717 0 ustar 00root root 0000000 0000000 sphinx-themes
=============
These are some themes for Python `Sphinx `_
documentation projects.
Preview
-------
To see how these themes look, visit http://vimalkumar.in/sphinx-themes
Download
--------
Released versions are available from https://github.com/vkvn/sphinx-themes/downloads
You can also download this repository as a `zip archive `_
Support
-------
If there are problems with any of these themes, you can file a bug report at
https://github.com/vkvn/sphinx-themes/issues
Themes are licensed under the
`GNU General Public License `_.
.. raw:: html
arrow-0.7.0/docs/_themes/f6/ 0000775 0000000 0000000 00000000000 12605232351 0015536 5 ustar 00root root 0000000 0000000 arrow-0.7.0/docs/_themes/f6/NEWS.txt 0000664 0000000 0000000 00000000107 12605232351 0017051 0 ustar 00root root 0000000 0000000 News
====
1.0
---
* Release date: 2012-11-01
* Initial release
arrow-0.7.0/docs/_themes/f6/README.rst 0000664 0000000 0000000 00000001500 12605232351 0017221 0 ustar 00root root 0000000 0000000 f6 theme for Python Sphinx
==========================
f6?
---
A light theme for Python Sphinx documentation projects. Mostly white -> #ffffff -> f6
Preview
-------
http://vimalkumar.in/sphinx-themes/f6
Download
--------
Released versions are available from http://github.com/vkvn/sphinx-themes/downloads
Installation
------------
#. Extract the archive.
#. Modify ``conf.py`` of an existing Sphinx project or create new project using ``sphinx-quickstart``.
#. Change the ``html_theme`` parameter to ``f6``.
#. Change the ``html_theme_path`` to the location containing the extracted archive.
License
-------
`GNU General Public License `_
Credits
-------
Modified from the default Sphinx theme -- Sphinxdoc
Background pattern from http://subtlepatterns.com
arrow-0.7.0/docs/_themes/f6/layout.html 0000664 0000000 0000000 00000004053 12605232351 0017743 0 ustar 00root root 0000000 0000000 {% extends "basic/layout.html" %}
{%- block doctype -%}
{%- endblock -%}
{%- block extrahead -%}
{%- endblock -%}
{# put the sidebar before the body #}
{% block sidebarlogo %}