Closed sentrworks closed 5 years ago
Ultimately this is a consistency issue with the API. I'll see if there's any hope of fixing the API itself by asking the devs in the discord chat. If not then instead perhaps I can perform some sort of detection and convert them all into proper datetime objects.
Unfortunately it seems this is either somewhat by design or changing it would be troublesome without sacrificing backwards compatibility. I've got a somewhat elegant solution on the develop branch that I'll be releasing soon.
@sentrworks feel free to give it a whirl if you can and let me know if you find any issues before I release it :)
@rhgrant10 unfortunately it doesn't work. Despite I upgraded to berserk 0.1.2 to 0.2.1, in both versions the api "lichess.games.export_by_player(username=username,as_pgn=False,max=how_many_games,rated='true',moves='false')" returns 'createdAt' field in a timestamp format which needs to divide by 1000.
Yeah it's still on the develop branch. I haven't released it yet. I should be able to get to it this weekend though.
It's available now on the PyPI at v0.3.0 @sentrworks.
Description
The timestamp types are not consistent between the services. While 'get_activity_feed(username)' returns timestamp in the format of python, 'export_by_player' returns Javascript timestamp.
Describe what you were trying to get done. 1- The ''export_by_player' API returns the timestamp value of milliseconds for 'createAt' parameter , e.g. '1541551788049' whereas the 'get_activity_feed(username)' API returns timestamp without milliseconds which compliance with python datetime parsers, e.g. '1541548800'
What I Did
I had to divide the timestamp values with '1000' if they have milliseconds as explained below.
JavaScript timestamp to Python datetime conversion: https://stackoverflow.com/questions/10286224/javascript-timestamp-to-python-datetime-conversion