Skip to content
Browse files

modified time to use second line reather than timestamp

  • Loading branch information...
1 parent 9712e58 commit db1e4ac427a7948834e729521a7af656b9057081 @dz committed
Showing with 11 additions and 10 deletions.
  1. +8 −7 chisel.py
  2. +1 −1 templates/archive.html
  3. +1 −1 templates/detail.html
  4. +1 −1 templates/home.html
View
15 chisel.py
@@ -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
@@ -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,
View
2 templates/archive.html
@@ -14,7 +14,7 @@
<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>
View
2 templates/detail.html
@@ -2,7 +2,7 @@
{% block header %}
<h2>{{ entry.title }}</h2>
- <p>{{ entry.date }}</p>
+ <p>{{ entry.pretty_date }}</p>
{% endblock %}
{% block main %}
View
2 templates/home.html
@@ -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>

0 comments on commit db1e4ac

Please sign in to comment.
Something went wrong with that request. Please try again.