* ``mysqlclient`` (former ``MySQLdb``) and ``PyMySQL`` will use the ``type()`` function to determine the type of the object by default. To work around it you can register a new adapter:
* ``mysqlclient`` (former ``MySQLdb``) and ``PyMySQL`` will use the ``type()`` function to determine the type of the object by default. To work around it you can register a new adapter:
* ``django`` will use the ``isoformat()`` method to store datetimes in the database. However since ``pendulum`` is always timezone aware the offset information will always be returned by ``isoformat()`` raising an error, at least for MySQL databases. To work around it you can either create your own ``DateTimeField`` or use the previous workaround for ``MySQLdb``:
* ``django`` will use the ``isoformat()`` method to store datetimes in the database. However since ``pendulum`` is always timezone aware the offset information will always be returned by ``isoformat()`` raising an error, at least for MySQL databases. To work around it you can either create your own ``DateTimeField`` or use the previous workaround for ``MySQLdb``:
.. code-block:: python
.. code-block:: python
from django.db.models import DateTimeField as BaseDateTimeField
from django.db.models import DateTimeField as BaseDateTimeField
Contributions are welcome, especially with localization.
Contributions are welcome, especially with localization.
Getting started
Getting started
---------------
---------------
To work on the Pendulum codebase, you'll want to clone the project locally
To work on the Pendulum codebase, you'll want to clone the project locally
and install the required depedendencies via `poetry <https://python-poetry.org>`_.
and install the required depedendencies via `poetry <https://python-poetry.org>`_.
.. code-block:: bash
.. code-block:: bash
$ git clone git@github.com:sdispater/pendulum.git
$ git clone git@github.com:sdispater/pendulum.git
$ poetry install
$ poetry install
Localization
Localization
------------
------------
If you want to help with localization, there are two different cases: the locale already exists
If you want to help with localization, there are two different cases: the locale already exists
or not.
or not.
If the locale does not exist you will need to create it by using the ``clock`` utility:
If the locale does not exist you will need to create it by using the ``clock`` utility:
.. code-block:: bash
.. code-block:: bash
./clock locale create <your-locale>
./clock locale create <your-locale>
It will generate a directory in ``pendulum/locales`` named after your locale, with the following
It will generate a directory in ``pendulum/locales`` named after your locale, with the following
structure:
structure:
.. code-block:: text
.. code-block:: text
<your-locale>/
<your-locale>/
- custom.py
- custom.py
- locale.py
- locale.py
The ``locale.py`` file must not be modified. It contains the translations provided by
The ``locale.py`` file must not be modified. It contains the translations provided by
the CLDR database.
the CLDR database.
The ``custom.py`` file is the one you want to modify. It contains the data needed
The ``custom.py`` file is the one you want to modify. It contains the data needed
by Pendulum that are not provided by the CLDR database. You can take the `en <https://github.com/sdispater/pendulum/tree/master/pendulum/locales/en/custom.py>`_
by Pendulum that are not provided by the CLDR database. You can take the `en <https://github.com/sdispater/pendulum/tree/master/pendulum/locales/en/custom.py>`_
data as a reference to see which data is needed.
data as a reference to see which data is needed.
You should also add tests for the created or modified locale.
You should also add tests for the created or modified locale.