Skip to main content

Django model for Japanese birthday.

Project description

django-jp-birthday

https://pypi.python.org/pypi/django_jp_birthday image https://img.shields.io:/pypi/djversions/django-jp-birthday https://django-jp-birthday.readthedocs.io/en/latest/?version=latest Updates Python 3 https://img.shields.io/github/repo-size/shimakaze-git/django-jp-birthday https://img.shields.io/github/languages/code-size/shimakaze-git/django-jp-birthday https://codecov.io/gh/shimakaze-git/django-jp-birthday/branch/master/graph/badge.svg https://img.shields.io/github/license/shimakaze-git/django-jp-birthday.svg image .github/workflows/test.yml

django-jp-birthday is a django's model for use Japanese birthdays and ages.

Based library is https://github.com/bashu/django-birthday .

Authored by shimakaze_soft and some great

contributors

Features

  • Converting Birthdays to Japanese Style
  • Get all birthdays in the specified Japanese calendar
  • Calculate age based on birthday

  • Get all user profiles within the next 30 days
  • Get all user profiles which have their birthday today
  • order the user profiles according to their birthday

Installation

$ pip install django-jp-birthday

$ python steup.py install

Usage

django-jp-birthday provides a jp_birthday.models.BirthdayModel model type which is a subclass of django.db.models.Model and thus has the same characteristics as that.

jp_birthday.managers.JpBirthdayManager is used as a manager for jp_birthday.models.BirthdayModel and provides various methods.

from jp_birthday.models import BirthdayModel

class ModelsTest(BirthdayModel):

    class Meta:
        app_label = 'jp_birthday'
        ordering = ('pk',)

Converting Birthdays to Japanese Style

# id: 1
# ["2001-01-01"]

m = ModelTest.objects.filter(id=1).first()
birthday = m.get_wareki_birthday()
# h-13-1-1

birthday = m.get_wareki_birthday(True)
# {'era': 'heisei', 'era_short': 'h', 'era_kanji': '平成', 'year': 13, 'month': 1, 'day': 1}

Get all birthdays in the specified Japanese calendar

# ["2001-01-01", "2000-01-02", "2002-12-31", "1980-03-01"]

birthdays = ModelTest.objects.get_wareki_birthdays("heisei")
# ["2001-01-01", "2000-01-02", "2002-12-31"]

birthdays = ModelTest.objects.get_wareki_birthdays("へいせい")
# ["2001-01-01", "2000-01-02", "2002-12-31"]

Calculate age based on birthday

# id: 1
# ["1995-01-05"]

m = ModelTest.objects.filter(id=1).first()
birthday = m.get_age()
# 27

Get all user profiles within the next 30 days

# ["2001-01-01", "2000-01-02", "2002-12-31"]

jan1 = date(year=2010, month=1, day=1)
birthdays = ModelsTest.objects.get_upcoming_birthdays(after=jan1)
# ["2001-01-01", "2000-01-02"]

Get all user profiles which have their birthday today

# ["2001-01-01", "2000-01-02", "2002-12-31", "1990-03-01"]

jan1 = date(year=2010, month=1, day=1)
birthdays = ModelsTest.objects.get_birthdays(jan1)

# ["2001-01-01", "1990-01-01"]

Order the user profiles according to their birthday

# ["2001-01-01", "2000-01-02", "2002-12-31", "1990-03-01"]

jan1 = date(year=2010, month=1, day=1)
birthdays = ModelsTest.objects.order_by_birthday()
# ["2001-01-01", "2000-01-02", "1990-03-01", "2002-12-31"]

Docs

License

django-jp-birthday is released under the MIT license.


HISTORY

v0.6.0 (2022-02-09)

Full Changelog

Merged pull requests:

v0.4.0 (2022-02-08)

Full Changelog

Merged pull requests:

v0.3.0 (2022-02-07)

Full Changelog

Merged pull requests:

v0.2.0 (2022-02-07)

Full Changelog

Closed issues:

  • Initial Update #30

Merged pull requests:

v0.1.5 (2022-01-29)

Full Changelog

Merged pull requests:

v0.1.4 (2022-01-29)

Full Changelog

Merged pull requests:

v0.1.3 (2022-01-28)

Full Changelog

Merged pull requests:

* This Changelog was automatically generated by github_changelog_generator

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

django_jp_birthday-0.7.0.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

django_jp_birthday-0.7.0-py2.py3-none-any.whl (12.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django_jp_birthday-0.7.0.tar.gz.

File metadata

  • Download URL: django_jp_birthday-0.7.0.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for django_jp_birthday-0.7.0.tar.gz
Algorithm Hash digest
SHA256 19816dbd11f0ec2c27318f2d07f4bdc465cf528728e63b9fcc39c751788aba05
MD5 0509e06561caece31d7a37a740c42b49
BLAKE2b-256 891baa17b25b27d7a8d2daf4d7ebb071b11dd71d5c276b7356b83ca9907a4c8f

See more details on using hashes here.

File details

Details for the file django_jp_birthday-0.7.0-py2.py3-none-any.whl.

File metadata

  • Download URL: django_jp_birthday-0.7.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for django_jp_birthday-0.7.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ca974a9fb64eea6d9fe82643ce4cde6c0b7a7c53aa06f0db1a3d0bae8ffbeffe
MD5 00290cec9ffa9f07d1eaac9465f3710c
BLAKE2b-256 9dcd6344947df1e5b861bb53c27808522061407b3871ac2193eb77aeb9bb4073

See more details on using hashes here.

Supported by

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