How to use the duration function from moment
Find comprehensive JavaScript moment.duration code examples handpicked from public code repositorys.
105 106 107 108 109 110 111 112 113 114
if (chat) fs.writeJSONSync(file_path, chat); return chat; } const convertTimestamp = (timestamp) => moment.duration(timestamp, 'seconds') .toISOString() .replace(/P.*?T(?:(\d+?)H)?(?:(\d+?)M)?(?:(\d+).*?S)?/, (_, ...ms) => { const seg = v => v ? v.padStart(2, '0') : '00';
220
0
32
GitHub: ferrolho/magnet-player
149 150 151 152 153 154 155 156 157
// Remaining time var remaining if (torrent.done) { remaining = 'Done' } else { remaining = moment.duration(torrent.timeRemaining / 1000, 'seconds').humanize() remaining = remaining[0].toUpperCase() + remaining.substring(1) + ' remaining' } $remaining.html(remaining)
138
456
27
GitHub: tracking-exposed/facebook
58 59 60 61 62 63 64 65 66 67
const printableTime = summary.publicationTime ? summary.publicationTime : moment(); const name = _.get(_.first(_.filter(_.get(summary, 'meaningfulId.local', []), { 'fblinktype': 'profile' })), 'text', null); const hashtags = _.map(_.filter(_.get(summary, 'meaningfulId.local', []), { 'fblinktype': 'hashtag' }), function(lt) { return '#' + lt.hashtag }); /* const vdiff = summary.publicationTime ? "in " + moment.duration( moment(summary.impressionTime) - moment(summary.publicationTime) ).humanize() : null; */ /* const images = (summary.images && summary.images.count) ? `${summary.images.count} img` : null;
45
107
37
+ 7 other calls in file
273 274 275 276 277 278 279 280 281 282 283 284
/** * Figures out what unit to format a set of ticks with */ function determineUnitForFormatting(ticks, minUnit, min, max) { var duration = moment.duration(moment(max).diff(moment(min))); var ilen = UNITS.length; var i, unit; for (i = ilen - 1; i >= UNITS.indexOf(minUnit); i--) {
0
1
1
4 5 6 7 8 9 10 11 12 13 14
} function getTimeInterval(startTime, endTime) { const start = moment(startTime, "HH:mm"); const end = moment(endTime, "HH:mm"); const interval = moment.duration(end.diff(start)); const hours = interval.asHours() >= 0 ? interval.asHours() : interval.asHours() + 24; return hours; }
0
0
0
moment.utc is the most popular function in moment (43 examples)