Skip to main content

Helper functions for easy string-based manipulation of dates in python

Project description

yyyy_mm_dd

Build Status

Easy string-based date manipulation library for Python

Documentation

Installation

$ pip install yyyy_mm_dd

Why?

When writing some python code for a quick investigation in a notebook, do you also think it's a lot of boilerplate to work with dates? Like, to add +1 day to a date? Do you always have to google the solution and copy it from stackoverflow because you never remember and just want the most quick and easy solution?

If you answered yes, then you are going to love this library. In yyyy_mm_dd you can work with strings directly, no need to convert back and forth:

>>> from yyyy_mm_dd import *
>>> move_yyyy_mm_dd("2020-03-14", 1)
'2020-03-15'

There are many operations in the library that you can do with a single functions, no need to think on how to compose them, the most common operations should have a function available, for example the amount of days between two dates:

>>> diff_yyyy_mm_dd("2020-03-14", "2020-03-16")
2

Same operations can be done at various levels, and the name is easy to remember, just using the pattern of the date itself (operation + yyyy_mm, yyyy_mm_dd, yyyy_mm_dd_hh_mm_ss, etc). For example the difference in months between two dates:

>>> diff_yyyy_mm("2020-03", "2020-07")
4
>>> diff_yyyy_mm("2020-03-01", "2020-07-01")
4

Or to add a month:

>>> move_yyyy_mm("2020-03-14", 1)
'2020-04-14'

Check the documentation to see all functions available, and if there is an operation you regularly need to do which is not there, please open an issue

TODO:

  • Support timezones
  • Make it fully compatible with RFC 3339

Contributing

Any contributions are very welcome. To run locally, install the dependencies:

pip install -r requirements.txt

The tests are inside the docs, to run them simply execute:

python -m doctest yyyy_mm_dd/__init__.py

If you want to check the type hints:

mypy yyyy_mm_dd

If you want to regenerate docs:

pdoc --html -o ./docs yyyy_mm_dd --force

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yyyy_mm_dd-0.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

yyyy_mm_dd-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file yyyy_mm_dd-0.1.1.tar.gz.

File metadata

  • Download URL: yyyy_mm_dd-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for yyyy_mm_dd-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8afa5e1c37e51450ed6e9c94ba617b3bab9afd09368afef8b8224b71221af5ea
MD5 c80dea60df730075666d4c7753b827f5
BLAKE2b-256 a1b744b59732b80118b9a2f29611b77f20000e72945a91f5cc281271137aa28f

See more details on using hashes here.

File details

Details for the file yyyy_mm_dd-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: yyyy_mm_dd-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for yyyy_mm_dd-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 964ddb6524c0fdcc66ca02a140650168cb06974a873c829b2a3d0e322e25520d
MD5 33a9cd8c436fba0f23457c1eb65709f7
BLAKE2b-256 4071cef418b28cbc42a7026492808cb6923348c31ede30f4be854e895a6b615e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page