simplify date parsing

and remove some whitespace
This commit is contained in:
Stephan Gabler 2012-05-14 21:44:30 +02:00
parent d4bd93779a
commit 448f56473d

View file

@ -175,7 +175,7 @@ class Journal:
for line in journal.split(os.linesep):
if line:
try:
new_date = datetime.fromtimestamp(time.mktime(time.strptime(line[:date_length], self.config['timeformat'])))
new_date = datetime.strptime(line[:date_length], self.config['timeformat'])
# make a journal entry of the current stuff first
if new_date and current_entry:
entries.append(current_entry)
@ -459,8 +459,8 @@ if __name__ == "__main__":
elif args.tags: # get all tags
# Astute reader: should the following line leave you as puzzled as me the first time
# I came across this construction, worry not and embrace the ensuing moment of enlightment.
tags = [tag
for entry in journal.entries
tags = [tag
for entry in journal.entries
for tag in set(entry.tags)
]
# To be read: [for entry in journal.entries: for tag in set(entry.tags): tag]