如何使用角度js

时间:2017-04-12 18:01:12

标签: angularjs

我正在尝试显示时间,这取决于值(值将以分钟为单位)我添加月/周/天/小时/分钟。我已经提出了这个功能:

function displayTimeRange (timeValue) {
            var message;
            var dateValue = Math.floor((timeValue / 60) / 24);
            var hourValue = Math.floor(timeValue / 60);
            if (dateValue > 1) {
                message = gettextCatalog.getString("{{time}} days", {time: dateValue}, null);
            } else if (hourValue > 1) {
                message = gettextCatalog.getString("in the last {{time}} hours", {time: hourValue}, null);
            } else if (hourValue === 1) {
                message = gettextCatalog.getString("in the last {{time}} hour", {time: hourValue}, null);
            } else {
                message = gettextCatalog.getString("in the last {{time}} minutes", {time: timeValue}, null);
            }
            return message;
        }

除此之外,如果是25小时,我希望它显示“1天1小时”而不是向上或向下舍入。我希望它更精确,如“3小时4分钟”或“4天10小时”等。 像Stackoverflow如何显示时间:

enter image description here

角度js是否有任何过滤器?任何人都可以推荐一些方法来做到这一点?

0 个答案:

没有答案