UNPKG

@applicaster/zapp-react-native-ui-components

Version:

Applicaster Zapp React Native ui components for the Quick Brick App

33 lines (26 loc) 887 B
export function millisecondsToTime(value) { const time = new Date(value / 0.001); const hours = time.getUTCHours() === 0 ? "" : time.getUTCHours() + ":"; const minutes = time.getUTCMinutes() <= 9 && hours > 0 ? "0" + time.getUTCMinutes() + ":" : time.getUTCMinutes() + ":"; const seconds = time.getUTCSeconds() <= 9 ? "0" + time.getUTCSeconds() : time.getUTCSeconds(); return hours + minutes + seconds; } export function getCurrentTimePercentage(currentTime, duration) { if (currentTime > 0) { return parseFloat(currentTime) / parseFloat(duration); } else { return 0; } } export function flexCompleted(currentTime, duration) { return getCurrentTimePercentage(currentTime, duration) * 100; } export function flexRemaining(currentTime, duration) { return (1 - this.getCurrentTimePercentage(currentTime, duration)) * 100; }