Skip to content

Commit

Permalink
Merge pull request #24 from kinegratii/develop
Browse files Browse the repository at this point in the history
Release v3.4.1
  • Loading branch information
kinegratii authored Nov 25, 2020
2 parents 8d22779 + dab4ef1 commit a30560a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion borax/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding=utf8

__version__ = '3.4.0'
__version__ = '3.4.1'
__author__ = 'kinegratii'
12 changes: 8 additions & 4 deletions borax/calendars/lunardate.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,10 @@ def month_cn(month: int) -> str:
def day_cn(day: int) -> str:
a, b = divmod(day, 10)
if b == 0: # 10,20,30
b = 10
if a == 1: # 10
a = 0
if a == 1:
return TextUtils.TENS[0] + TextUtils.DAYS_CN[10]
else:
return TextUtils.DAYS_CN[a] + TextUtils.DAYS_CN[10]
return TextUtils.TENS[a] + TextUtils.DAYS_CN[b]

@staticmethod
Expand Down Expand Up @@ -456,7 +457,10 @@ def cn_month_num(self) -> str:
@property
def cn_day_calendar(self) -> str:
if self.day == 1:
return self.cn_month
if self.leap:
return '闰{}'.format(self.cn_month)
else:
return '{}月'.format(self.cn_month)
else:
return self.cn_day

Expand Down
2 changes: 1 addition & 1 deletion borax/htmls.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ def html_tag(tag_name, content=None, **kwargs):
if content:
return HTMLString('<{0} {1}>{2}</{0}>'.format(tag_name, html_params(**kwargs), content))
else:
return HTMLString('<{0} {1} />'.format(tag_name, html_params(**kwargs)))
return HTMLString('<{0} {1}>'.format(tag_name, html_params(**kwargs)))
8 changes: 8 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# 更新日志

## v3.4.1 (20201125)

- **`borax.calendars.lunarDate`**
- 修正农历日中文名称 `LunarDate.cn_day` 二十、三十日表示错误的BUG ([#22](https://github.com/kinegratii/borax/issues/22)
- 修正日历日名称 `LunarDate.cn_day_calendar` 表示错误的BUG([#20](https://github.com/kinegratii/borax/issues/20)
- **`borax.htmls`**
- 移除html自闭合标签不必要的斜杠字符

## v3.4.0 (20201115)

> 新增 Python3.9构建支持
Expand Down
2 changes: 1 addition & 1 deletion tests/test_htmls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class HtmlTagTest(unittest.TestCase):
def test_html_tags(self):
html = html_tag('img', id_='idDemoImg', src='/demo.png')
self.assertEqual(html, '<img id="idDemoImg" src="/demo.png" />')
self.assertEqual(html, '<img id="idDemoImg" src="/demo.png">')
html = html_tag('div', content='Test', id_='idDemo', data_my_attr='23')
self.assertEqual(html, '<div id="idDemo" data-my-attr="23">Test</div>')

Expand Down
24 changes: 23 additions & 1 deletion tests/test_lunardate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@
import unittest
from datetime import date, timedelta

from borax.calendars.lunardate import LunarDate, parse_year_days, LCalendars, InvalidLunarDateError
from borax.calendars.lunardate import LunarDate, parse_year_days, LCalendars, InvalidLunarDateError, TextUtils


class TextUtilsTestCase(unittest.TestCase):
def test_cn_day_text(self):
data = [
(1, '初一'),
(10, '初十'),
(14, '十四'),
(20, '二十'),
(23, '廿三'),
(30, '三十')
]
for value, text in data:
with self.subTest(value=value, text=text):
self.assertEqual(text, TextUtils.day_cn(value))


class LunarDateTestCase(unittest.TestCase):
Expand Down Expand Up @@ -127,6 +142,7 @@ def test_valid_format(self):
ld2 = LunarDate(2018, 11, 23)
self.assertEqual('二〇一八/冬/廿三', ld2.strftime('%Y/%M/%D'))
self.assertEqual('二〇一八/十一/廿三', ld2.strftime('%Y/%N/%D'))
self.assertEqual('廿三', ld2.strftime('%F'))

ld3 = LunarDate(2017, 6, 3, 1)
self.assertEqual('61', ld3.strftime('%m%l'))
Expand All @@ -143,6 +159,12 @@ def test_term(self):
ld = LunarDate(2020, 3, 23)
self.assertEqual('tem:-', ld.strftime('tem:%t'))

def test_cn_calendar_day(self):
ld = LunarDate(2017, 6, 1, 1)
self.assertEqual('闰六', ld.strftime('%F'))
ld1 = LunarDate(2017, 11, 1, 0)
self.assertEqual('冬月', ld1.strftime('%F'))


class LCalendarTestCase(unittest.TestCase):
def test_ndays(self):
Expand Down

0 comments on commit a30560a

Please sign in to comment.