Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/874431 )
Change subject: [doc] Update documentation ......................................................................
[doc] Update documentation
Change-Id: Ie29fbe475f05e6723ee623744014e891b48e239d --- M pywikibot/__init__.py M ROADMAP.rst M pywikibot/page/_wikibase.py M tests/wikibase_tests.py 4 files changed, 26 insertions(+), 10 deletions(-)
Approvals: Xqt: Verified; Looks good to me, approved
diff --git a/ROADMAP.rst b/ROADMAP.rst index 4a0ef7b..59ae273 100644 --- a/ROADMAP.rst +++ b/ROADMAP.rst @@ -50,6 +50,7 @@ Bugfixes ^^^^^^^^
+* Normalize :class:`WbTimes<pywikibot.WbTime>` sent to Wikidata (:phab:`T325860`) * Fix :class:`pywikibot.WbTime` precision (:phab:`T324798`) * Unquote title for red-links in class:`proofreadpage.IndexPage` * Find month with first letter uppercase or lowercase with :class:`textlib.TimeStripper` (:phab:`T324310`) diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index 49bf812..8aea5a8 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -667,11 +667,13 @@
def toTimestr(self, force_iso: bool = False, normalize: bool = False) -> str: - """ - Convert the data to a UTC date/time string. + """Convert the data to a UTC date/time string.
- See fromTimestr() for differences between output with and without - force_iso. + .. seealso:: :meth:`fromTimestr` for differences between output + with and without *force_iso* parameter. + + .. versionchanged:: 8.0 + *normalize* parameter was added.
:param force_iso: whether the output should be forced to ISO 8601 :param normalize: whether the output should be normalized (see @@ -701,8 +703,10 @@ self.toTimestr(force_iso=True).lstrip('+'))
def toWikibase(self, normalize: bool = False) -> Dict[str, Any]: - """ - Convert the data to a JSON object for the Wikibase API. + """Convert the data to a JSON object for the Wikibase API. + + .. versionchanged:: 8.0 + *normalize* parameter was added.
:param normalize: Whether to normalize the WbTime object before converting it to a JSON object (see :func:`normalize` for details) diff --git a/pywikibot/page/_wikibase.py b/pywikibot/page/_wikibase.py index eedbbbd..07115bd 100644 --- a/pywikibot/page/_wikibase.py +++ b/pywikibot/page/_wikibase.py @@ -9,7 +9,7 @@ * WikibaseEntity: base interface for Wikibase entities. """ # -# (C) Pywikibot team, 2013-2022 +# (C) Pywikibot team, 2013-2023 # # Distributed under the terms of the MIT license. # @@ -1904,8 +1904,10 @@ for qualifier in self.qualifiers.get(qualifier_id, []))
def _formatValue(self) -> dict: - """ - Format the target into the proper JSON value that Wikibase wants. + """Format the target into the proper JSON value that Wikibase wants. + + .. versionchanges:: 8.0 + normalize the result if type is ``time``.
:return: JSON value """ diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py index ac15c61..3bb61e5 100755 --- a/tests/wikibase_tests.py +++ b/tests/wikibase_tests.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 """Tests for the Wikidata parts of the page module.""" # -# (C) Pywikibot team, 2008-2022 +# (C) Pywikibot team, 2008-2023 # # Distributed under the terms of the MIT license. #
pywikibot-commits@lists.wikimedia.org