Repository: crsmithdev/arrow
Pull request #776 (2020-04-24 05:34:33)

Add week support for zh_tw locale
Also adds missing tests for timeframes

## Pull Request Checklist

Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all *appropriate* boxes:

<!-- Check boxes by placing an x in the brackets: [x] -->
- [x] 🧪 Added **tests** for changed code.
- [x] 🛠️ All tests **pass** when run locally (run `tox` or `make test` to find out!).
- [n/a] 📚 Updated **documentation** for changed code.
- [x] ⏩ Code is **up-to-date** with the `master` branch.

If you have *any* questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!

## Description of Changes

<!--
Replace with description of code changes.

If your PR has an associated issue, insert the issue number (e.g. #703) or directly link to the GitHub issue (e.g. https://github.com/crsmithdev/arrow/issues/703).

For example, doing the following will automatically close issue #703 when this PR is merged:

Closes: #703
-->


codecov-io: # [Codecov](https://codecov.io/gh/crsmithdev/arrow/pull/776?src=pr&el=h1) Report
> Merging [#776](https://codecov.io/gh/crsmithdev/arrow/pull/776?src=pr&el=desc) into [master](https://codecov.io/gh/crsmithdev/arrow/commit/d03dee5c85244993c1a0a36a6915e4574ebb9924&el=desc) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/crsmithdev/arrow/pull/776/graphs/tree.svg?width=650&height=150&src=pr&token=4EkGnFsIGn)](https://codecov.io/gh/crsmithdev/arrow/pull/776?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##            master      #776   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         1694      1680   -14     
  Branches       289       289           
=========================================
- Hits          1694      1680   -14     
```


| [Impacted Files](https://codecov.io/gh/crsmithdev/arrow/pull/776?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [arrow/locales.py](https://codecov.io/gh/crsmithdev/arrow/pull/776/diff?src=pr&el=tree#diff-YXJyb3cvbG9jYWxlcy5weQ==) | `100.00% <100.00%> (ø)` | |
| [arrow/arrow.py](https://codecov.io/gh/crsmithdev/arrow/pull/776/diff?src=pr&el=tree#diff-YXJyb3cvYXJyb3cucHk=) | `100.00% <0.00%> (ø)` | |
| [arrow/parser.py](https://codecov.io/gh/crsmithdev/arrow/pull/776/diff?src=pr&el=tree#diff-YXJyb3cvcGFyc2VyLnB5) | `100.00% <0.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/crsmithdev/arrow/pull/776?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/crsmithdev/arrow/pull/776?src=pr&el=footer). Last update [d03dee5...8c6b6b7](https://codecov.io/gh/crsmithdev/arrow/pull/776?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/arrow/locales.py b/arrow/locales.py
index 36e07f9..d33fb88 100644
--- a/arrow/locales.py
+++ b/arrow/locales.py
@@ -908,17 +908,20 @@ class ChineseTWLocale(Locale):
 
     past = "{0}前"
     future = "{0}後"
+    and_word = "和"
 
     timeframes = {
         "now": "剛才",
-        "second": "一秒",
-        "seconds": "{0}幾秒",
+        "second": "1秒",
+        "seconds": "{0}秒",
         "minute": "1分鐘",
         "minutes": "{0}分鐘",
         "hour": "1小時",
         "hours": "{0}小時",
         "day": "1天",
         "days": "{0}天",
+        "week": "1週",
+        "weeks": "{0}週",
         "month": "1個月",
         "months": "{0}個月",
         "year": "1年",
@@ -956,7 +959,7 @@ class ChineseTWLocale(Locale):
         "12",
     ]
 
-    day_names = ["", "周一", "周二", "周三", "周四", "周五", "周六", "周日"]
+    day_names = ["", "週一", "週二", "週三", "週四", "週五", "週六", "週日"]
     day_abbreviations = ["", "一", "二", "三", "四", "五", "六", "日"]
 
 


Test patch:
diff --git a/tests/test_locales.py b/tests/test_locales.py
index 0125763..0e749a8 100644
--- a/tests/test_locales.py
+++ b/tests/test_locales.py
@@ -842,3 +842,23 @@ class TestHongKongLocale:
         assert self.locale._format_timeframe("months", 11) == "11個月"
         assert self.locale._format_timeframe("year", 1) == "1年"
         assert self.locale._format_timeframe("years", 12) == "12年"
+
+
+@pytest.mark.usefixtures("lang_locale")
+class TestChineseTWLocale:
+    def test_format_timeframe(self):
+        assert self.locale._format_timeframe("now", 0) == "剛才"
+        assert self.locale._format_timeframe("second", 1) == "1秒"
+        assert self.locale._format_timeframe("seconds", 30) == "30秒"
+        assert self.locale._format_timeframe("minute", 1) == "1分鐘"
+        assert self.locale._format_timeframe("minutes", 40) == "40分鐘"
+        assert self.locale._format_timeframe("hour", 1) == "1小時"
+        assert self.locale._format_timeframe("hours", 23) == "23小時"
+        assert self.locale._format_timeframe("day", 1) == "1天"
+        assert self.locale._format_timeframe("days", 12) == "12天"
+        assert self.locale._format_timeframe("week", 1) == "1週"
+        assert self.locale._format_timeframe("weeks", 38) == "38週"
+        assert self.locale._format_timeframe("month", 1) == "1個月"
+        assert self.locale._format_timeframe("months", 11) == "11個月"
+        assert self.locale._format_timeframe("year", 1) == "1年"
+        assert self.locale._format_timeframe("years", 12) == "12年"