ILIAS
ILIAS copied to clipboard
NPM: Add `moment`
trafficstars
This PR adds moment as NPM dependency.
Usage:
- Calendar: ./components/ILIAS/Calendar/classes/class.ilCalendarUtil.php
- Legacy Forms: Implicitly by
ilCalendarUtilin theilDateTimeInputGUIfield type - OnScreenChat: ./components/ILIAS/OnScreenChat/js/moment.js
- It is mainly (but not only) used to display relative dates and especially times (locale aware) in the conversation windows. These date/time presentations are dynamically updated (without expensive server round-trips) every 60 seconds:
setInterval(() => {
$('[data-livestamp]').each(() => {
let $this = $(this);
$this.html(dateTimeFormatter.fromNowToTime($this.data("livestamp")));
});
$('[data-message-time]').each(() => {
let $this = $(this);
$this.attr("title", dateTimeFormatter.format($this.data("message-time", "LT")));
});
}, 60000);
Wrapped By:
- OnScreenChat: https://github.com/ILIAS-eLearning/ILIAS/blob/trunk/components/ILIAS/OnScreenChat/js/moment.js
Reasoning:
momentis a JavaScript library to parse, validate, manipulate and display dates and times in JavaScript. It has been initially introduced by theCalendarcomponent and is still used there. I guess it has been added as dependency because at that time JavaScript did not support any locale aware date/time formatting. As a project we could agree upon a migration to the native JavaScriptIntl.DateTimeFormatandIntl.RelativeTimeFormatpackages for client-side date.
Maintenance:
momentis actively maintained.
Links:
- NPM: https://www.npmjs.com/package/moment
- GitHub: https://github.com/moment/moment
- Documentation: https://momentjs.com/docs/
This is the same PR as #6891 but with the correct upstream.
Jour Fixe, 22 JAN 2024: Dependency is accepted for ILIAS 10.
This should have become part of ILIAS 10 via this PR. As always, something might have gone wrong. If you are still missing that package, please ping me.
Kind regards!