summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-12-15 12:03:52 -0800
committerLance Stout <lancestout@gmail.com>2011-12-15 12:03:52 -0800
commita7a2fd1d5bd770e0df2c2df240acd57fe5e40ea9 (patch)
treec1e4f63365e92a01c87f82b7607a0ac9a7ecd8d9 /sleekxmpp
parentdcb0d8b00ec9d81f75b9b7f2cbd8fb785eafa507 (diff)
parentd496417deb5a2c87fe8ad639e82d2b19ce94fc30 (diff)
downloadslixmpp-a7a2fd1d5bd770e0df2c2df240acd57fe5e40ea9.tar.gz
slixmpp-a7a2fd1d5bd770e0df2c2df240acd57fe5e40ea9.tar.bz2
slixmpp-a7a2fd1d5bd770e0df2c2df240acd57fe5e40ea9.tar.xz
slixmpp-a7a2fd1d5bd770e0df2c2df240acd57fe5e40ea9.zip
Merge branch 'develop' into develop-1.1
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/plugins/xep_0082.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/sleekxmpp/plugins/xep_0082.py b/sleekxmpp/plugins/xep_0082.py
index b1bb0263..25c80fd0 100644
--- a/sleekxmpp/plugins/xep_0082.py
+++ b/sleekxmpp/plugins/xep_0082.py
@@ -76,7 +76,7 @@ def format_datetime(time_obj):
return '%sZ' % timestamp
return timestamp
-def date(year=None, month=None, day=None):
+def date(year=None, month=None, day=None, obj=False):
"""
Create a date only timestamp for the given instant.
@@ -86,6 +86,8 @@ def date(year=None, month=None, day=None):
year -- Integer value of the year (4 digits)
month -- Integer value of the month
day -- Integer value of the day of the month.
+ obj -- If True, return the date object instead
+ of a formatted string. Defaults to False.
"""
today = dt.datetime.utcnow()
if year is None:
@@ -94,9 +96,12 @@ def date(year=None, month=None, day=None):
month = today.month
if day is None:
day = today.day
- return format_date(dt.date(year, month, day))
+ value = dt.date(year, month, day)
+ if obj:
+ return value
+ return format_date(value)
-def time(hour=None, min=None, sec=None, micro=None, offset=None):
+def time(hour=None, min=None, sec=None, micro=None, offset=None, obj=False):
"""
Create a time only timestamp for the given instant.
@@ -110,6 +115,8 @@ def time(hour=None, min=None, sec=None, micro=None, offset=None):
offset -- Either a positive or negative number of seconds
to offset from UTC to match a desired timezone,
or a tzinfo object.
+ obj -- If True, return the time object instead
+ of a formatted string. Defaults to False.
"""
now = dt.datetime.utcnow()
if hour is None:
@@ -124,12 +131,14 @@ def time(hour=None, min=None, sec=None, micro=None, offset=None):
offset = tzutc()
elif not isinstance(offset, dt.tzinfo):
offset = tzoffset(None, offset)
- time = dt.time(hour, min, sec, micro, offset)
- return format_time(time)
+ value = dt.time(hour, min, sec, micro, offset)
+ if obj:
+ return value
+ return format_time(value)
def datetime(year=None, month=None, day=None, hour=None,
min=None, sec=None, micro=None, offset=None,
- separators=True):
+ separators=True, obj=False):
"""
Create a datetime timestamp for the given instant.
@@ -146,6 +155,8 @@ def datetime(year=None, month=None, day=None, hour=None,
offset -- Either a positive or negative number of seconds
to offset from UTC to match a desired timezone,
or a tzinfo object.
+ obj -- If True, return the datetime object instead
+ of a formatted string. Defaults to False.
"""
now = dt.datetime.utcnow()
if year is None:
@@ -167,9 +178,11 @@ def datetime(year=None, month=None, day=None, hour=None,
elif not isinstance(offset, dt.tzinfo):
offset = tzoffset(None, offset)
- date = dt.datetime(year, month, day, hour,
+ value = dt.datetime(year, month, day, hour,
min, sec, micro, offset)
- return format_datetime(date)
+ if obj:
+ return value
+ return format_datetime(value)
class xep_0082(base_plugin):