Last modified: 2014-07-26 09:42:11 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T66501, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 64501 - Modify pywikibot.Timestamp to support Wikidata
Modify pywikibot.Timestamp to support Wikidata
Status: RESOLVED WONTFIX
Product: Pywikibot
Classification: Unclassified
Wikidata (Other open bugs)
core-(2.0)
All All
: Unprioritized normal
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-04-27 13:05 UTC by Maarten Dammers
Modified: 2014-07-26 09:42 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Maarten Dammers 2014-04-27 13:05:26 UTC
Pywikibot currently contains a Timestamp class (see https://git.wikimedia.org/blob/pywikibot%2Fcore.git/HEAD/pywikibot%2F__init__.py).

This class should be modified like Coordinate to support Wikidata.

Example how to add a time claim:

'action' => 'wbcreateclaim',
'entity' => 'Q82',
'property' => 'P11',
'snaktype' => 'value',
'value' => '{"time":"+00000002010-01-02T00:00:00Z","timezone":0,"before":0,"after":0,"precision":11,"calendarmodel":"http://www.wikidata.org/entity/Q1985727"}',
'bot' => 1,

(from https://www.mediawiki.org/wiki/Extension:Wikibase_Repository/API)

Should probably at least implement "toWikibase" and "fromWikibase"
Comment 1 Mpaa 2014-04-27 13:45:01 UTC
There is already class WbTime(object) with the methods above. Shouldn't we extend this class instead, with a method that accepts a pywikibot.Timestamp as input ("fromTimeStampToWbTime" or similar?)?
Comment 2 Maarten Dammers 2014-04-27 13:49:25 UTC
I completely overlooked WbTime. Shouldn't the two of them be merged into one object?
Comment 3 Kunal Mehta (Legoktm) 2014-04-27 23:40:55 UTC
(In reply to Maarten Dammers from comment #2)
> I completely overlooked WbTime. Shouldn't the two of them be merged into one
> object?

Ideally yes. But I don't believe it's possible.

pywikibot.Timestamp is an extension of datetime.datetime, which has a limit on how large dates it can handle. <https://docs.python.org/2.7/library/datetime.html> says the year has to be between 1 and 9999, but Wikibase supports much older dates, or dates farther in the future, which is why we needed WbTime.

I think creating a fromTimeStampToWbTime or similar function is probably the best way to handle it for now.
Comment 4 Ricordisamoa 2014-04-28 00:38:00 UTC
(In reply to Mpaa from comment #1)
> There is already class WbTime(object) with the methods above. Shouldn't we
> extend this class instead, with a method that accepts a pywikibot.Timestamp
> as input ("fromTimeStampToWbTime" or similar?)?

pywikibot.WbTime.fromTimestr(timestamp.toISOformat()) already works perfectly.

(In reply to Maarten Dammers from comment #2)
> I completely overlooked WbTime. Shouldn't the two of them be merged into one
> object?

Maybe, but WbTime has Wikibase-specific attributes like "precision", "after", "before" and "calendarmodel".
Comment 5 Amir Ladsgroup 2014-07-25 13:48:06 UTC
So I think closing this bug is okay, Does anyone disagree?
Comment 6 Ricordisamoa 2014-07-26 01:23:51 UTC
Yes, WONTFIX.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links