Skip to content

Commit

Permalink
modified time to use second line reather than timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
dz committed Mar 3, 2009
1 parent 9712e58 commit db1e4ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions chisel.py
Expand Up @@ -20,7 +20,7 @@
'detail': "detail.html",
'archive': "archive.html",
}
TIME_FORMAT = "%B %d, %Y - %I:%M %p"
TIME_FORMAT = "%B %d, %Y"

#FORMAT should be a callable that takes in text
#and returns formatted text
Expand All @@ -43,16 +43,17 @@ def get_tree(source):
for root, ds, fs in os.walk(source):
for name in fs:
path = os.path.join(root, name)
epoch = os.path.getmtime(path)
date = time.localtime(epoch)
year, month, day = map(int, date[:3])
f = codecs.open(path, "r", encoding="utf-8")
title = f.readline()
date = time.strptime(f.readline().strip(), "%m/%d/%Y")
year, month, day = date[:3]
files.append({
'title': f.readline(),
'title': title,
'epoch': time.mktime(date),
'content': FORMAT(''.join(f.readlines()[1:])),
'url': '/'.join([str(year), "%.2d" % month, "%.2d" % day, os.path.splitext(name)[0] + ".html"]),
'date': time.strftime(TIME_FORMAT, date),
'epoch': epoch,
'pretty_date': time.strftime(TIME_FORMAT, date),
'date': date,
'year': year,
'month': month,
'day': day,
Expand Down
2 changes: 1 addition & 1 deletion templates/archive.html
Expand Up @@ -14,7 +14,7 @@ <h4>{{month}}</h4>
<ul class="month_block">
{% for day, day_list in month_list|groupby('day') %}
{% for entry in day_list %}
<li><a href="/{{ entry.url }}">{{ entry.title }}</a> -- <small>{{ entry.date }}</small></li>
<li><a href="/{{ entry.url }}">{{ entry.title }}</a> -- <small>{{ entry.pretty_date }}</small></li>
{% endfor %}
{% endfor %}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion templates/detail.html
Expand Up @@ -2,7 +2,7 @@

{% block header %}
<h2>{{ entry.title }}</h2>
<p>{{ entry.date }}</p>
<p>{{ entry.pretty_date }}</p>
{% endblock %}

{% block main %}
Expand Down
2 changes: 1 addition & 1 deletion templates/home.html
Expand Up @@ -4,7 +4,7 @@
{% for entry in entries %}
<div class="entry">
<h2><a href="/{{ entry.url }}">{{ entry.title }}</a></h2>
<h3>{{ entry.date }}</h3>
<h3>{{ entry.pretty_date }}</h3>
<div class="entry_content">
{{ entry.content }}
</div>
Expand Down

0 comments on commit db1e4ac

Please sign in to comment.