Skip to content

Commit

Permalink
Merge pull request #69 from shimakaze-git/master
Browse files Browse the repository at this point in the history
v0.8.0
  • Loading branch information
shimakaze-git committed Feb 10, 2022
2 parents 6f41a15 + 12efaac commit 05110a1
Show file tree
Hide file tree
Showing 21 changed files with 521 additions and 112 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
open-pull-requests-limit: 10
# commit-message:
# prefix: chore
70 changes: 70 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ develop ]
schedule:
- cron: '38 14 * * 2'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
on:
pull_request:
branches:
- dependabot/*
types: [open]
push:
branches:
- master
Expand Down
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 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)
Expand Down
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
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)
-----------------------------------------------------------------------------------------

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ lint/black: ## check style with black

lint: lint/flake8 lint/black ## check style

shell:
python tests/manage.py shell

test-one: ## run tests quickly with the default Python
tox -e py38-django30 $(TEST_PATH)
# make test-one TEST_PATH=tests.test_init
Expand Down
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
![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)
Expand All @@ -26,6 +27,8 @@ Authored by [shimakaze_soft](https://github.com/shimakaze-git) and some great
- 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

-----

Expand Down Expand Up @@ -66,22 +69,22 @@ class ModelsTest(BirthdayModel):
# ["2001-01-01"]

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

birthday = m.get_wareki_birthday(True)
# {'era': 'heisei', 'era_short': 'h', 'era_kanji': '平成', 'year': 13, 'month': 1, 'day': 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_wareki_birthdays("heisei")
birthdays = ModelTest.objects.get_jp_era_birthdays("heisei")
# ["2001-01-01", "2000-01-02", "2002-12-31"]

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

Expand All @@ -96,6 +99,30 @@ 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
Expand All @@ -109,7 +136,7 @@ birthdays = ModelsTest.objects.get_upcoming_birthdays(after=jan1)
## Get all user profiles which have their birthday today

```Python
# ["2001-01-01", "2000-01-02", "2002-12-31", "1990-03-01"]
# ["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)
Expand Down
44 changes: 37 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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|
|Updates| |Python 3| |Total alerts|
|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|
Expand All @@ -27,6 +27,8 @@ 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

--------------

Expand Down Expand Up @@ -74,11 +76,11 @@ Converting Birthdays to Japanese Style
# ["2001-01-01"]
m = ModelTest.objects.filter(id=1).first()
birthday = m.get_wareki_birthday()
birthday = m.get_jp_era_birthday()
# h-13-1-1
birthday = m.get_wareki_birthday(True)
# {'era': 'heisei', 'era_short': 'h', 'era_kanji': '平成', 'year': 13, 'month': 1, 'day': 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
----------------------------------------------------
Expand All @@ -87,10 +89,10 @@ 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")
birthdays = ModelTest.objects.get_jp_era_birthdays("heisei")
# ["2001-01-01", "2000-01-02", "2002-12-31"]
birthdays = ModelTest.objects.get_wareki_birthdays("へいせい")
birthdays = ModelTest.objects.get_jp_era_birthdays("へいせい")
# ["2001-01-01", "2000-01-02", "2002-12-31"]
Calculate age based on birthday
Expand All @@ -105,6 +107,32 @@ Calculate age based on birthday
birthday = m.get_age()
# 27
Get the zodiac
--------------

.. code:: python
# ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
# id: 1
# ["1995-01-05"]
m = ModelTest.objects.filter(id=1).first()
birthday = m.get_zodiac()
#
Years of the Japanese era
-------------------------

.. code:: 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
---------------------------------------------

Expand All @@ -121,7 +149,7 @@ Get all user profiles which have their birthday today

.. code:: python
# ["2001-01-01", "2000-01-02", "2002-12-31", "1990-03-01"]
# ["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)
Expand Down Expand Up @@ -158,6 +186,8 @@ License
:target: https://pyup.io/repos/github/shimakaze-git/django-jp-birthday/
.. |Python 3| image:: https://pyup.io/repos/github/shimakaze-git/django-jp-birthday/python-3-shield.svg
:target: https://pyup.io/repos/github/shimakaze-git/django-jp-birthday/
.. |Total alerts| image:: https://img.shields.io/lgtm/alerts/g/shimakaze-git/django-jp-birthday.svg?logo=lgtm&logoWidth=18
:target: https://lgtm.com/projects/g/shimakaze-git/django-jp-birthday/alerts/
.. |https://img.shields.io/github/repo-size/shimakaze-git/django-jp-birthday| image:: 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| image:: 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| image:: https://codecov.io/gh/shimakaze-git/django-jp-birthday/branch/master/graph/badge.svg
Expand Down
2 changes: 1 addition & 1 deletion jp_birthday/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """shimakaze-git"""
__email__ = "shimakaze.soft+github@googlemail.com"
__version__ = "0.7.0"
__version__ = "0.8.0"

__copyright__ = "Copyright (C) 2020 shimakaze-git"
__license__ = "MIT"
Expand Down
6 changes: 4 additions & 2 deletions jp_birthday/eras.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def get_date_range_from_jp_era(self, jp_era: str) -> dict:
"""
return self.jtw._get_date_range_from_jp_era(jp_era)

def get_jp_era_range(self, birthday: datetime.date) -> int:
def get_jp_era_years(self, birthday: datetime.date) -> int:
"""
get_jp_era_range
get_jp_era_years
Args:
birthday (datetime.date): [description]
Expand Down Expand Up @@ -138,10 +138,12 @@ def _convert_to_jp_era(self, year: int, month: int, day: int) -> dict:
era_en = reading["en"]
era_en_short = era_en[0]
era_kanji = era
era_jp = reading["jp"]

return {
"era": era_en,
"era_short": era_en_short,
"era_jp": era_jp,
"era_kanji": era_kanji,
"year": int(era_year),
"month": int(month),
Expand Down
Loading

0 comments on commit 05110a1

Please sign in to comment.