Merge pull request #352 from levivm/feature/added_localtime

Feature/added localtime

The time shows up fine on the VM order confirmation and the ssh keys page both on chrome and firefox.
This commit is contained in:
Pcoder 2017-06-29 21:27:11 +02:00 committed by GitHub
commit 381ac1fea0
4 changed files with 40 additions and 4 deletions

View file

@ -162,6 +162,12 @@
<!-- Gen SSH Key lib -->
<script type="text/javascript" src="{% static 'hosting/js/gen-ssh-key.js' %}"></script>
<!-- Moment -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.js"></script>
</body>
</html>

View file

@ -35,7 +35,7 @@
<div class="col-xs-6 text-right">
<address>
<strong>{% trans "Date"%}:</strong><br>
{{order.created_at}}<br><br>
<span id="order-created_at">{{order.created_at|date:'Y-m-d H:i'}}</span><br><br>
<strong>{% trans "Status:"%}</strong><br>
<strong class="{% if order.status == 'Approved' %}text-success
{%else%} text-danger
@ -81,4 +81,17 @@
</div>
{% endif %}
</div>
<script type="text/javascript">
window.onload = function () {
var locale_date = moment.utc(document.getElementById("order-created_at").textContent,'YYYY-MM-DD HH:mm').toDate();
locale_date = moment(locale_date).format("YYYY-MM-DD h:mm:ss a");
document.getElementById('order-created_at').innerHTML = locale_date;
};
</script>
{%endblock%}

View file

@ -24,7 +24,7 @@
{% for order in orders %}
<tr>
<td scope="row">{{ order.id }}</td>
<td>{{ order.created_at }}</td>
<td>{{ order.created_at | date:"M d, Y" }}</td>
<td>{{ order.price }} CHF</td>
<td>{% if order.approved %}
<span class="text-success strong">{% trans "Approved"%}</span>

View file

@ -32,7 +32,8 @@
{% for user_key in keys %}
<tr>
<td scope="row">{{user_key.name}}</td>
<td>{{user_key.created_at}}</td>
<td><span id="ssh-created_at-{{user_key.id}}">{{user_key.created_at|date:'Y-m-d H:i' }}</span></td>
<td>
<span class="h3 label label-success"><strong>Active</strong></span>
</td>
@ -92,5 +93,21 @@
</script>
{% endif %}
<script type="text/javascript">
window.onload = function () {
{% for user_key in keys %}
// var locale_date = new Date(document.getElementById("ssh-created_at-{{user_key.id}}").textContent).toISOString();
var locale_date = moment.utc(document.getElementById("ssh-created_at-{{user_key.id}}").textContent,'YYYY-MM-DD HH:mm').toDate();
locale_date = moment(locale_date).format("YYYY-MM-DD h:mm:ss a");
document.getElementById('ssh-created_at-{{user_key.id}}').innerHTML = locale_date;
{% endfor %}
};
</script>
{%endblock%}