Skip to content

Commit

Permalink
chg: [website] Improved display of the date for the combined sightings.
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricbonhomme committed Nov 13, 2024
1 parent 48610fc commit 908bb3c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion website/web/templates/bundles/bundle.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% block head %}
{{ super() }}
<script src="{{ url_for('static', filename='js/pretty-print-json.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/luxon.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/utils.js') }}"></script>
<link rel="stylesheet" href="{{ url_for('static', filename='css/pretty-print-json.css') }}" />
{% endblock %}
Expand Down Expand Up @@ -101,7 +102,9 @@ <h2>Combined sightings</h2>
row.appendChild(typeCell);

const dateCell = document.createElement("td");
dateCell.textContent = new Date(sighting.creation_timestamp).toLocaleString();
dateCell.classList.add('datetime');
dateCell.textContent = sighting.creation_timestamp;
dateCell.title = sighting.creation_timestamp;
row.appendChild(dateCell);

tableBody.appendChild(row);
Expand All @@ -124,6 +127,14 @@ <h2>Combined sightings</h2>
// Add each sighting as a row in the table
sightingData.data.forEach(sighting => addRowToTable(sighting));
})
.then(_ => {
var DateTime = luxon.DateTime;
elements = document.getElementsByClassName("datetime");
Array.prototype.forEach.call(elements, function(element) {
element.textContent = DateTime.fromISO(element.title).toRelative();

});
})
.catch(error => console.error("Error fetching sighting:", error));
});
})
Expand Down

0 comments on commit 908bb3c

Please sign in to comment.