import {__, _x, _n, _nx} from '@wordpress/i18n'; export function VideoSize({video}) { const sizeOf = function (bytes) { if (bytes === 0) { return '0 B'; } var e = Math.floor(Math.log(bytes) / Math.log(1024)); return ( (bytes / Math.pow(1024, e)).toFixed(1) + ' ' + ' KMGTP'.charAt(e) + 'B' ); }; return ( {sizeOf(video.storageSize)} ); } export function VideoLength({video}) { //function to turn seconds into a human readable time const secondsToTime = function (seconds) { var h = Math.floor(seconds / 3600); var m = Math.floor((seconds % 3600) / 60); var s = Math.floor((seconds % 3600) % 60); return ( (h > 0 ? h + ':' : '') + (m > 0 ? (h > 0 && m < 10 ? '0' : '') + m + ':' : '0:') + (s < 10 ? '0' : '') + s ); }; return ( {secondsToTime(video.length)} ); } export function VideoViews({video}) { return ( {video.views} ); } export function VideoDate({video}) { //change datetime to human-readable in localstring const dateTime = function (date) { return new Date(date).toLocaleString(); }; return ( {dateTime(video.dateUploaded)} ); }