Skip to content

Commit

Permalink
Date formatting to solve issue #16
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamgilbert committed Apr 9, 2014
1 parent 47e7533 commit 7f38513
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/templates/server/machine_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ <h3>Managed Software Update</h3>
{% if machine.last_puppet_run %}
<tr>
<th>Puppet Run:</th>
<td>{{ machine.last_puppet_run }}</td>
<td>{{ machine.last_puppet_run|format_date }}</td>
</tr>
{% endif %}
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions server/templates/server/overview_list_all.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "base.html" %}
{% load i18n %}

{% load dashboard_extras %}
{% block script %}
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
Expand Down Expand Up @@ -45,7 +45,7 @@
</td>

<td>{{ item.console_user }}</td>
<td>{{ item.last_checkin }}</td>
<td>{{ item.last_checkin|format_date }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
8 changes: 6 additions & 2 deletions server/templatetags/dashboard_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@ def bu_machine_count(bu_id):
def convert_datetime(string):
"""Converts a string into a formatted date"""
the_date = datetime.strptime(string, "%Y-%m-%d %H:%M:%S +0000")
return date(the_date, "N j, Y, P")

return date(the_date, "Y-m-d H:i")

@register.filter
def format_date(string):
"""Converts a date object into something that can be sorted separately"""
return date (string, "Y-m-d H:i")

0 comments on commit 7f38513

Please sign in to comment.