diff options
author | Lorenz Diener <[email protected]> | 2019-04-28 20:38:49 +0200 |
---|---|---|
committer | Lorenz Diener <[email protected]> | 2019-04-28 20:38:49 +0200 |
commit | 20a640eb7ee4628979252743c567d31cab4dbb91 (patch) | |
tree | f316f3998ccab9e36d7882899433cd95ee312ffb /mastodon | |
parent | ee4549acd0a6fa75bfea1a3e0498ef2029af5c9f (diff) | |
download | mastodon.py-20a640eb7ee4628979252743c567d31cab4dbb91.tar.gz |
Fix the isoformat formatter
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index c037ceb..679aac8 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -1381,7 +1381,7 @@ class Mastodon: | |||
1381 | in_reply_to_id = self.__unpack_id(in_reply_to_id) | 1381 | in_reply_to_id = self.__unpack_id(in_reply_to_id) |
1382 | 1382 | ||
1383 | if scheduled_at != None: | 1383 | if scheduled_at != None: |
1384 | scheduled_at = scheduled_at.astimezone(pytz.utc).isoformat() | 1384 | scheduled_at = self.__consistent_isoformat_utc(scheduled_at) |
1385 | 1385 | ||
1386 | params_initial = locals() | 1386 | params_initial = locals() |
1387 | 1387 | ||
@@ -1585,7 +1585,7 @@ class Mastodon: | |||
1585 | 1585 | ||
1586 | Returns a `scheduled toot dict`_ | 1586 | Returns a `scheduled toot dict`_ |
1587 | """ | 1587 | """ |
1588 | scheduled_at = scheduled_at.astimezone(pytz.utc).isoformat() | 1588 | scheduled_at = self.__consistent_isoformat_utc(scheduled_at) |
1589 | id = self.__unpack_id(id) | 1589 | id = self.__unpack_id(id) |
1590 | params = self.__generate_params(locals(), ['id']) | 1590 | params = self.__generate_params(locals(), ['id']) |
1591 | url = '/api/v1/scheduled_statuses/{0}'.format(str(id)) | 1591 | url = '/api/v1/scheduled_statuses/{0}'.format(str(id)) |
@@ -2406,12 +2406,27 @@ class Mastodon: | |||
2406 | 2406 | ||
2407 | @staticmethod | 2407 | @staticmethod |
2408 | def __json_hooks(json_object): | 2408 | def __json_hooks(json_object): |
2409 | """ | ||
2410 | All the json hooks. Used in request parsing. | ||
2411 | """ | ||
2409 | json_object = Mastodon.__json_strnum_to_bignum(json_object) | 2412 | json_object = Mastodon.__json_strnum_to_bignum(json_object) |
2410 | json_object = Mastodon.__json_date_parse(json_object) | 2413 | json_object = Mastodon.__json_date_parse(json_object) |
2411 | json_object = Mastodon.__json_truefalse_parse(json_object) | 2414 | json_object = Mastodon.__json_truefalse_parse(json_object) |
2412 | json_object = Mastodon.__json_allow_dict_attrs(json_object) | 2415 | json_object = Mastodon.__json_allow_dict_attrs(json_object) |
2413 | return json_object | 2416 | return json_object |
2414 | 2417 | ||
2418 | @staticmethod | ||
2419 | def __consistent_isoformat_utc(datetime_val): | ||
2420 | """ | ||
2421 | Function that does what isoformat does but it actually does the same | ||
2422 | every time instead of randomly doing different things on some systems | ||
2423 | and also it represents that time as the equivalent UTC time. | ||
2424 | """ | ||
2425 | isotime = datetime_val.astimezone(pytz.utc).strftime("%Y-%m-%dT%H:%M:%S%z") | ||
2426 | if isotime[-2] != ":": | ||
2427 | isotime = isotime[:-2] + ":" + isotime[-2:] | ||
2428 | return isotime | ||
2429 | |||
2415 | def __api_request(self, method, endpoint, params={}, files={}, headers={}, access_token_override=None, do_ratelimiting=True): | 2430 | def __api_request(self, method, endpoint, params={}, files={}, headers={}, access_token_override=None, do_ratelimiting=True): |
2416 | """ | 2431 | """ |
2417 | Internal API request helper. | 2432 | Internal API request helper. |