django-jp-birthday 0.8.0
Django model for Japanese birthday.
License: MIT license
Requires Python: >=3.6
Keywords: django_jp_birthday django birthday era

# django-jp-birthday

![https://pypi.python.org/pypi/django_jp_birthday](https://img.shields.io/pypi/v/django_jp_birthday.svg)
[![image](https://img.shields.io/pypi/pyversions/django-jp-birthday.svg)](https://pypi.org/project/django-jp-birthday)
![https://img.shields.io:/pypi/djversions/django-jp-birthday](https://img.shields.io:/pypi/djversions/django-jp-birthday)
![https://django-jp-birthday.readthedocs.io/en/latest/?version=latest](https://readthedocs.org/projects/django-jp-birthday/badge/?version=latest)
[![Updates](https://pyup.io/repos/github/shimakaze-git/django-jp-birthday/shield.svg)](https://pyup.io/repos/github/shimakaze-git/django-jp-birthday/)
[![Python 3](https://pyup.io/repos/github/shimakaze-git/django-jp-birthday/python-3-shield.svg)](https://pyup.io/repos/github/shimakaze-git/django-jp-birthday/)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/shimakaze-git/django-jp-birthday.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/shimakaze-git/django-jp-birthday/alerts/)
![https://img.shields.io/github/repo-size/shimakaze-git/django-jp-birthday](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://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://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](https://img.shields.io/github/license/shimakaze-git/django-jp-birthday.svg)
[![image](https://img.shields.io/pypi/dm/django-jp-birthday)](https://img.shields.io/pypi/dm/django-jp-birthday)
[![.github/workflows/test.yml](https://github.com/shimakaze-git/django-jp-birthday/actions/workflows/test.yml/badge.svg)](https://github.com/shimakaze-git/django-jp-birthday/actions/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](https://github.com/bashu/django-birthday) .

Authored by [shimakaze_soft](https://github.com/shimakaze-git) and some great

[contributors](https://github.com/shimakaze-git/django-jp-birthday/CONTRIBUTING.rst)

# Features

- Converting Birthdays to Japanese Style
- Get all birthdays in the specified Japanese calendar
- Calculate age based on birthday
- Get the zodiac
- Years of the Japanese era

-----

- 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

- [pypi](https://pypi.org/project/django-jp-birthday/)

```Bash
$ 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.

```Python
from jp_birthday.models import BirthdayModel

class ModelsTest(BirthdayModel):

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

## Converting Birthdays to Japanese Style

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

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

birthday = m.get_jp_era_birthday(True)
# {'era': 'heisei', 'era_short': 'h', 'era_jp': 'へいせい', 'era_kanji': '平成', 'year': 13, 'month': 1, 'day': 1}
```

## Get all birthdays in the specified Japanese calendar

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

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

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

## Calculate age based on birthday

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

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

## Get the zodiac

```Python
# ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]

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

m = ModelTest.objects.filter(id=1).first()
birthday = m.get_zodiac()
# 亥
```

## Years of the Japanese era

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

m = ModelTest.objects.filter(id=1).first()
birthday = m.get_jp_era_years()
# 31
```

## Get all user profiles within the next 30 days

```Python
# ["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

```Python
# ["2001-01-01", "2000-01-02", "2002-12-31", "1990-03-01", "1990-01-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

```Python
# ["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

- Documentation: https://django-jp-birthday.readthedocs.io.

# License

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



 -------- 


# HISTORY

## [v0.7.0](https://github.com/shimakaze-git/django-jp-birthday/tree/v0.7.0) (2022-02-09)

[Full Changelog](https://github.com/shimakaze-git/django-jp-birthday/compare/v0.6.0...v0.7.0)

## [v0.6.0](https://github.com/shimakaze-git/django-jp-birthday/tree/v0.6.0) (2022-02-09)

[Full Changelog](https://github.com/shimakaze-git/django-jp-birthday/compare/v0.4.0...v0.6.0)

**Merged pull requests:**

- v0.6.0 [\#51](https://github.com/shimakaze-git/django-jp-birthday/pull/51) ([github-actions[bot]](https://github.com/apps/github-actions))
- version 0.6をリリース [\#50](https://github.com/shimakaze-git/django-jp-birthday/pull/50) ([shimakaze-git](https://github.com/shimakaze-git))
- get\_jp\_era\_rangeを追加. [\#49](https://github.com/shimakaze-git/django-jp-birthday/pull/49) ([shimakaze-git](https://github.com/shimakaze-git))
- Feature/fix gh actions [\#48](https://github.com/shimakaze-git/django-jp-birthday/pull/48) ([shimakaze-git](https://github.com/shimakaze-git))

## [v0.4.0](https://github.com/shimakaze-git/django-jp-birthday/tree/v0.4.0) (2022-02-08)

[Full Changelog](https://github.com/shimakaze-git/django-jp-birthday/compare/v0.3.0...v0.4.0)

**Merged pull requests:**

- v0.4.0 [\#47](https://github.com/shimakaze-git/django-jp-birthday/pull/47) ([github-actions[bot]](https://github.com/apps/github-actions))
- バージョン4.0をデプロイ [\#46](https://github.com/shimakaze-git/django-jp-birthday/pull/46) ([shimakaze-git](https://github.com/shimakaze-git))
- 干支を表示する機能を作成. [\#45](https://github.com/shimakaze-git/django-jp-birthday/pull/45) ([shimakaze-git](https://github.com/shimakaze-git))

## [v0.3.0](https://github.com/shimakaze-git/django-jp-birthday/tree/v0.3.0) (2022-02-07)

[Full Changelog](https://github.com/shimakaze-git/django-jp-birthday/compare/v0.2.0...v0.3.0)

**Merged pull requests:**

- v0.3.0 [\#44](https://github.com/shimakaze-git/django-jp-birthday/pull/44) ([github-actions[bot]](https://github.com/apps/github-actions))
- 0.3.0にアップデート [\#43](https://github.com/shimakaze-git/django-jp-birthday/pull/43) ([shimakaze-git](https://github.com/shimakaze-git))
- Versionを0.2.3にする [\#41](https://github.com/shimakaze-git/django-jp-birthday/pull/41) ([shimakaze-git](https://github.com/shimakaze-git))

## [v0.2.0](https://github.com/shimakaze-git/django-jp-birthday/tree/v0.2.0) (2022-02-07)

[Full Changelog](https://github.com/shimakaze-git/django-jp-birthday/compare/v0.1.5...v0.2.0)

**Closed issues:**

- Initial Update [\#30](https://github.com/shimakaze-git/django-jp-birthday/issues/30)

**Merged pull requests:**

- v0.2.0 [\#40](https://github.com/shimakaze-git/django-jp-birthday/pull/40) ([github-actions[bot]](https://github.com/apps/github-actions))
- Versionを0.2にアップロード. [\#39](https://github.com/shimakaze-git/django-jp-birthday/pull/39) ([shimakaze-git](https://github.com/shimakaze-git))
- v0.1.5 [\#37](https://github.com/shimakaze-git/django-jp-birthday/pull/37) ([github-actions[bot]](https://github.com/apps/github-actions))
- fix: git pushの処理を追加. [\#36](https://github.com/shimakaze-git/django-jp-birthday/pull/36) ([shimakaze-git](https://github.com/shimakaze-git))

## [v0.1.5](https://github.com/shimakaze-git/django-jp-birthday/tree/v0.1.5) (2022-01-29)

[Full Changelog](https://github.com/shimakaze-git/django-jp-birthday/compare/v0.1.4...v0.1.5)

**Merged pull requests:**

- v0.1.5 [\#35](https://github.com/shimakaze-git/django-jp-birthday/pull/35) ([github-actions[bot]](https://github.com/apps/github-actions))
- develop to master. [\#34](https://github.com/shimakaze-git/django-jp-birthday/pull/34) ([shimakaze-git](https://github.com/shimakaze-git))

## [v0.1.4](https://github.com/shimakaze-git/django-jp-birthday/tree/v0.1.4) (2022-01-29)

[Full Changelog](https://github.com/shimakaze-git/django-jp-birthday/compare/v0.1.3...v0.1.4)

**Merged pull requests:**

- v0.1.4 [\#33](https://github.com/shimakaze-git/django-jp-birthday/pull/33) ([github-actions[bot]](https://github.com/apps/github-actions))
- 0.1.4にバージョンアップ. [\#32](https://github.com/shimakaze-git/django-jp-birthday/pull/32) ([shimakaze-git](https://github.com/shimakaze-git))
- Config file for pyup.io [\#31](https://github.com/shimakaze-git/django-jp-birthday/pull/31) ([pyup-bot](https://github.com/pyup-bot))
- v0.1.3 [\#29](https://github.com/shimakaze-git/django-jp-birthday/pull/29) ([github-actions[bot]](https://github.com/apps/github-actions))
- fix: templateを修正していく. [\#28](https://github.com/shimakaze-git/django-jp-birthday/pull/28) ([shimakaze-git](https://github.com/shimakaze-git))
- \[v0.1.3\] \(2022-01-29\) [\#27](https://github.com/shimakaze-git/django-jp-birthday/pull/27) ([github-actions[bot]](https://github.com/apps/github-actions))
- fix: add HISTORY.rstを削除していく. [\#26](https://github.com/shimakaze-git/django-jp-birthday/pull/26) ([shimakaze-git](https://github.com/shimakaze-git))
- \[v0.1.3\] \(2022-01-29\) [\#25](https://github.com/shimakaze-git/django-jp-birthday/pull/25) ([github-actions[bot]](https://github.com/apps/github-actions))
- develop to master [\#24](https://github.com/shimakaze-git/django-jp-birthday/pull/24) ([shimakaze-git](https://github.com/shimakaze-git))

## [v0.1.3](https://github.com/shimakaze-git/django-jp-birthday/tree/v0.1.3) (2022-01-28)

[Full Changelog](https://github.com/shimakaze-git/django-jp-birthday/compare/515815cbe454ff9b0caf506429079c329f91a11e...v0.1.3)

**Merged pull requests:**

- v0.1.3 [\#23](https://github.com/shimakaze-git/django-jp-birthday/pull/23) ([github-actions[bot]](https://github.com/apps/github-actions))
- develop to master. [\#22](https://github.com/shimakaze-git/django-jp-birthday/pull/22) ([shimakaze-git](https://github.com/shimakaze-git))
- v0.1.3 [\#21](https://github.com/shimakaze-git/django-jp-birthday/pull/21) ([github-actions[bot]](https://github.com/apps/github-actions))
- 0.1.3に変更 [\#20](https://github.com/shimakaze-git/django-jp-birthday/pull/20) ([shimakaze-git](https://github.com/shimakaze-git))
- Develop to Master. [\#18](https://github.com/shimakaze-git/django-jp-birthday/pull/18) ([shimakaze-git](https://github.com/shimakaze-git))
- refactor: プルリク先をreleaseに変更. [\#16](https://github.com/shimakaze-git/django-jp-birthday/pull/16) ([shimakaze-git](https://github.com/shimakaze-git))
- Develop to Master [\#15](https://github.com/shimakaze-git/django-jp-birthday/pull/15) ([shimakaze-git](https://github.com/shimakaze-git))
- Develop [\#14](https://github.com/shimakaze-git/django-jp-birthday/pull/14) ([shimakaze-git](https://github.com/shimakaze-git))
- fix: ワークフローの環境変数を色々表示させる. [\#12](https://github.com/shimakaze-git/django-jp-birthday/pull/12) ([shimakaze-git](https://github.com/shimakaze-git))
- fix: master-prを修正する. [\#11](https://github.com/shimakaze-git/django-jp-birthday/pull/11) ([shimakaze-git](https://github.com/shimakaze-git))
- fix: ci周りとreleaseのブランチを変更. [\#10](https://github.com/shimakaze-git/django-jp-birthday/pull/10) ([shimakaze-git](https://github.com/shimakaze-git))
- feat: ciを追加して整備する. [\#9](https://github.com/shimakaze-git/django-jp-birthday/pull/9) ([shimakaze-git](https://github.com/shimakaze-git))
- release 0.1 [\#8](https://github.com/shimakaze-git/django-jp-birthday/pull/8) ([shimakaze-git](https://github.com/shimakaze-git))
- 一度templateを取り込む. [\#2](https://github.com/shimakaze-git/django-jp-birthday/pull/2) ([shimakaze-git](https://github.com/shimakaze-git))



\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*