summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0082.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-07-03 13:40:57 -0700
committerLance Stout <lancestout@gmail.com>2011-07-03 13:41:15 -0700
commitc98f5d44509f5b6fdfdbf7408dae3282caccc9db (patch)
tree65a73ec7486470086459bd6130d8f7683697f35b /sleekxmpp/plugins/xep_0082.py
parent2e8e542bc9391e49cb901217f77915f42cdd8c17 (diff)
downloadslixmpp-c98f5d44509f5b6fdfdbf7408dae3282caccc9db.tar.gz
slixmpp-c98f5d44509f5b6fdfdbf7408dae3282caccc9db.tar.bz2
slixmpp-c98f5d44509f5b6fdfdbf7408dae3282caccc9db.tar.xz
slixmpp-c98f5d44509f5b6fdfdbf7408dae3282caccc9db.zip
Fix some bugs in time handling.
Namely, minutes and seconds were reversed.
Diffstat (limited to 'sleekxmpp/plugins/xep_0082.py')
-rw-r--r--sleekxmpp/plugins/xep_0082.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/sleekxmpp/plugins/xep_0082.py b/sleekxmpp/plugins/xep_0082.py
index e36e062b..785ba36b 100644
--- a/sleekxmpp/plugins/xep_0082.py
+++ b/sleekxmpp/plugins/xep_0082.py
@@ -105,8 +105,9 @@ def time(hour=None, min=None, sec=None, micro=None, offset=None):
min -- Integer value of the number of minutes.
sec -- Integer value of the number of seconds.
micro -- Integer value of the number of microseconds.
- offset -- A positive or negative number of seconds to
- offset from UTC to match a desired timezone.
+ offset -- Either a positive or negative number of seconds
+ to offset from UTC to match a desired timezone,
+ or a tzinfo object.
"""
now = dt.datetime.utcnow()
if hour is None:
@@ -119,7 +120,7 @@ def time(hour=None, min=None, sec=None, micro=None, offset=None):
micro = now.microsecond
if offset is None:
offset = tzutc()
- else:
+ elif not isinstance(offset, dt.tzinfo):
offset = tzoffset(None, offset)
time = dt.time(hour, min, sec, micro, offset)
return format_time(time)
@@ -140,8 +141,9 @@ def datetime(year=None, month=None, day=None, hour=None,
min -- Integer value of the number of minutes.
sec -- Integer value of the number of seconds.
micro -- Integer value of the number of microseconds.
- offset -- A positive or negative number of seconds to
- offset from UTC to match a desired timezone.
+ offset -- Either a positive or negative number of seconds
+ to offset from UTC to match a desired timezone,
+ or a tzinfo object.
"""
now = dt.datetime.utcnow()
if year is None:
@@ -160,11 +162,11 @@ def datetime(year=None, month=None, day=None, hour=None,
micro = now.microsecond
if offset is None:
offset = tzutc()
- else:
+ elif not isinstance(offset, dt.tzinfo):
offset = tzoffset(None, offset)
date = dt.datetime(year, month, day, hour,
- sec, min, micro, offset)
+ min, sec, micro, offset)
return format_datetime(date)
class xep_0082(base_plugin):