parent
d26795dce8
commit
9cf933723f
|
@ -73,7 +73,7 @@ item_updated = atom03:updated
|
||||||
mode = json
|
mode = json
|
||||||
|
|
||||||
mimetype = application/json
|
mimetype = application/json
|
||||||
timeformat = YYYY-MM-DDTHH:MM:SS
|
timeformat = %Y-%m-%dT%H:%M:%SZ
|
||||||
base = {}
|
base = {}
|
||||||
|
|
||||||
title = title
|
title = title
|
||||||
|
|
|
@ -232,10 +232,12 @@ class ParserBase(object):
|
||||||
# format
|
# format
|
||||||
try:
|
try:
|
||||||
time = parse_time(x)
|
time = parse_time(x)
|
||||||
return time.strftime(self.rules['timeformat'])
|
return time.strftime(self.rules.get('timeformat', self.default_timeformat))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
default_timeformat = "%D"
|
||||||
|
|
||||||
# HELPERS
|
# HELPERS
|
||||||
|
|
||||||
def get_raw(self, rule_name):
|
def get_raw(self, rule_name):
|
||||||
|
@ -466,11 +468,14 @@ class ParserHTML(ParserXML):
|
||||||
def parse_time(value):
|
def parse_time(value):
|
||||||
if isinstance(value, basestring):
|
if isinstance(value, basestring):
|
||||||
if re.match(r'^[0-9]+$', value):
|
if re.match(r'^[0-9]+$', value):
|
||||||
return datetime.fromtimestamp(int(value), tz.tzutc())
|
return datetime.fromtimestamp(int(value), tz.UTC)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return dateutil.parser.parse(value, tzinfos=tz.tzutc)
|
return dateutil.parser.parse(value)
|
||||||
|
|
||||||
elif isinstance(value, int):
|
elif isinstance(value, int):
|
||||||
return datetime.fromtimestamp(value, tz.tzutc())
|
return datetime.fromtimestamp(value, tz.UTC)
|
||||||
|
|
||||||
elif isinstance(value, datetime):
|
elif isinstance(value, datetime):
|
||||||
return value
|
return value
|
||||||
else:
|
else:
|
||||||
|
@ -661,12 +666,12 @@ class Item(Uniq):
|
||||||
lambda f,x: f.set_str('item_content', x),
|
lambda f,x: f.set_str('item_content', x),
|
||||||
lambda f: f.rmv('item_content') )
|
lambda f: f.rmv('item_content') )
|
||||||
time = property(
|
time = property(
|
||||||
lambda f: f.time_fmt(f.get_str('item_time')),
|
lambda f: f.time_prs(f.get_str('item_time')),
|
||||||
lambda f,x: f.set_str('title', f.time_prs(x)),
|
lambda f,x: f.set_str('item_time', f.time_fmt(x)),
|
||||||
lambda f: f.rmv('item_time') )
|
lambda f: f.rmv('item_time') )
|
||||||
updated = property(
|
updated = property(
|
||||||
lambda f: f.time_fmt(f.get_str('item_updated')),
|
lambda f: f.time_prs(f.get_str('item_updated')),
|
||||||
lambda f,x: f.set_str('updated', f.time_prs(x)),
|
lambda f,x: f.set_str('item_updated', f.time_fmt(x)),
|
||||||
lambda f: f.rmv('item_updated') )
|
lambda f: f.rmv('item_updated') )
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue