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
- Converting Birthdays to Japanese Style
- Get all birthdays from specified Japanese calendar
- Calculate age based on birthday
- Get the zodiac
- Get all birthdays from specified 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
$ pip install django-jp-birthday
$ python steup.py install
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',)
# 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}
# ["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"]
# id: 1
# ["1995-01-05"]
m = ModelTest.objects.filter(id=1).first()
birthday = m.get_age()
# 27
# ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
# id: 1
# ["1995-01-05"]
m = ModelTest.objects.filter(id=1).first()
birthday = m.get_zodiac()
# 亥
# ["2001-01-01", "2000-01-02", "2002-12-31", "1980-03-01", "1995-02-01", "1995-12-01"]
birthdays = ModelTest.objects.get_zodiac_birthdays("亥")
# ["1995-02-01", "1995-12-01"]
# id: 1
# ["1995-01-05"]
m = ModelTest.objects.filter(id=1).first()
birthday = m.get_jp_era_years()
# 31
# ["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"]
# ["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"]
# ["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"]
- Documentation: https://django-jp-birthday.readthedocs.io.
django-jp-birthday
is released under the MIT license.