daily pastebin goal
71%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. hhmmssToMillis(hhmmss) {
  2.    let time= hhmmss.split(':').reverse();
  3.    let millis = 0;
  4.    switch(time.length) {
  5.      case 1:
  6.          millis = parseInt(time[0]) * 1000;
  7.          break;
  8.      case 2:
  9.          millis = (parseInt(time[1]) * 60 + parseInt(time[0])) * 1000;
  10.          break;
  11.      case 3:
  12.          millis = (parseInt(time[2]) * 60 * 60 + parseInt(time[1]) * 60 + parseInt(time[0])) * 1000;
  13.          break;
  14.    }
  15.    return millis;
  16. }
  17.    
  18. let time= hhmmss.split(':').reverse();
  19. return time.reduce((millis, current, index) => {
  20.    return millis + parseInt(current) * 60 ** index;
  21. }, 0) * 1000;
  22.    
  23. hhmmssToMillis(hhmmss) {
  24.     const time = hhmmss.split(':').reverse();
  25.     switch(time.length) {
  26.        case 1:
  27.          return parseInt(time[0]) * 1000;
  28.        case 2:
  29.          return (parseInt(time[1]) * 60 + parseInt(time[0])) * 1000;
  30.        case 3:
  31.          return (parseInt(time[2]) * 60 * 60 + parseInt(time[1]) * 60 + parseInt(time[0])) * 1000;
  32.     }
  33.     return 0;
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top