Utils y mejoras en release

This commit is contained in:
Daniel Cortes
2020-06-16 05:07:36 -04:00
parent 81862efd80
commit 6550208bdd
3 changed files with 42 additions and 11 deletions

24
src/services/utils.js Normal file
View File

@@ -0,0 +1,24 @@
export const capitalize = (string) => {
return string.charAt(0).toUpperCase() + string.slice(1);
}
export const pad2 = (n) => {
if(n <= 99 && n >= 0) {
n = (`0${n}`).slice(-2);
}
return n;
}
export const toDuration = (miliseconds) => {
const base = Math.round(miliseconds / 1000);
const hours = Math.floor(base / 3600);
const minutes = Math.floor((base % 3600) / 60);
const seconds = base % 60;
if(hours > 0){
return pad2(hours) + ':' + pad2(minutes) + ':' + pad2(seconds)
}else{
return pad2(minutes) + ':' + pad2(seconds)
}
}