Utilisation de moment.js sur K-Psul

Parce que bon, ça fait un peu plus sérieux
This commit is contained in:
Aurélien Delobelle 2016-08-23 04:35:09 +02:00
parent 8f76986f89
commit f7e9cceb70
2 changed files with 13 additions and 20 deletions

View file

@ -8,6 +8,9 @@
<script type="text/javascript" src="{% static 'kfet/js/reconnecting-websocket.js' %}"></script>
<script type="text/javascript" src="{% static 'kfet/js/jquery-ui.min.js' %}"></script>
<script type="text/javascript" src="{% static 'kfet/js/jquery-confirm.js' %}"></script>
<script type="text/javascript" src="{% static 'moment.js' %}"></script>
<script type="text/javascript" src="{% static 'moment-fr.js' %}"></script>
<script type="text/javascript" src="{% static 'moment-timezone-with-data-2010-2020.js' %}"></script>
{% endblock %}
{% block title %}K-Psul{% endblock %}
@ -280,14 +283,8 @@ $(document).ready(function() {
var at_formated = '';
if (checkout_data['last_statement_at']) {
last_statement_container.html(last_statement_html_default);
at = new Date(checkout_data['last_statement_at']);
var at_date = at.getDate();
var at_month = at.getMonth()+1;
var at_year = at.getFullYear();
var at_hours = at.getHours();
var at_minutes = (at.getMinutes() < 10 ? '0' : '') + at.getMinutes();
var at_seconds = (at.getSeconds() < 10 ? '0' : '') + at.getSeconds();
at_formated = at_date+'/'+at_month+'/'+at_year+' à '+at_hours+':'+at_minutes;
var at = moment.tz(checkout_data['last_statement_at'], 'UTC');
at_formated = at.tz('Europe/Paris').format('DD/MM/YY à HH:mm');
} else {
last_statement_container.html('');
}
@ -1003,11 +1000,8 @@ $(document).ready(function() {
function getOpegroupHtml(opegroup) {
var opegroup_html = $(history_operationgroup_html);
var at = new Date(opegroup['at']);
var at_hours = (at.getHours() < 10 ? '0' : '') + at.getHours();
var at_minutes = (at.getMinutes() < 10 ? '0' : '') + at.getMinutes();
var at_seconds = (at.getSeconds() < 10 ? '0' : '') + at.getSeconds();
var at_formated = at_hours+':'+at_minutes+':'+at_seconds;
var at = moment.tz(opegroup['at'], 'UTC');
var at_formated = at.tz('Europe/Paris').format('HH:mm:ss');
var amount = parseFloat(opegroup['amount']);
var trigramme = opegroup['on_acc__trigramme'];
if (opegroup['on_acc__trigramme'] == 'LIQ') {
@ -1044,17 +1038,16 @@ $(document).ready(function() {
}
var history_day_default_html = '<div class="day"></div>';
var months = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'];
function checkOrCreateDay(at) {
var at = new Date(at);
var at = moment.tz(at, 'UTC').tz('Europe/Paris');
var mostRecentDay = history_container.find('.day').first();
if (mostRecentDay.length == 0 || at.getMonth() != mostRecentDay.attr('data-month') || at.getDate() != mostRecentDay.attr('data-day')) {
if (mostRecentDay.length == 0 || at.month() != mostRecentDay.attr('data-month') || at.date() != mostRecentDay.attr('data-day')) {
var day_html = $(history_day_default_html);
day_html
.attr('data-month', at.getMonth())
.attr('data-day', at.getDate())
.text(at.getDate()+' '+months[at.getMonth()]);
.attr('data-month', at.month())
.attr('data-day', at.date())
.text(at.format('D MMMM'));
history_container.prepend(day_html);
}
}

View file

@ -984,7 +984,7 @@ def kpsul_history(request):
'id', 'amount', 'at', 'checkout_id', 'is_cof',
'valid_by__trigramme', 'on_acc__trigramme')
.select_related('valid_by', 'on_acc')
.filter(at__gt=timezone.now()-timedelta(hours=4)))
.filter(at__gt=timezone.now()-timedelta(hours=24)))
opegroups = { opegroup['id']:opegroup for opegroup in opegroups_list }
for opegroup in opegroups:
opegroups[opegroup]['opes'] = []