Advertisement
Cristian-Paolini

_calcularTiempoPendiente

Jan 27th, 2023
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. _calcularTiempoPendiente: function (EstimIngrDate,EstimIngrTime, TurnNo) { // debe recibir TurnNo también
  2.             TurnNo = Number(TurnNo);
  3.             let tiempoPendiente;
  4.             if (TurnNo > 0) {
  5.             let today = new Date();
  6.             let horaIngEstim = new Date(EstimIngrTime.ms);
  7.             // EntrAnnouncedDate.setTime(EntrAnnouncedTime.ms)
  8.  
  9.             let TZOffsetMs = new Date(0).getTimezoneOffset() * 60 * 1000;
  10.             let fechaIngEstim = new Date(EstimIngrTime.ms + TZOffsetMs)
  11.             fechaIngEstim.setFullYear(EstimIngrDate.getFullYear())
  12.             fechaIngEstim.setDate(EstimIngrDate.getDate())
  13.             fechaIngEstim.setMonth(EstimIngrDate.getMonth())
  14.  
  15.             let diffMs = (today - fechaIngEstim);
  16.             // let diffDays = Math.floor(diffMs / 86400000); // days
  17.             let diffHrs = Math.floor((diffMs /*% 86400000*/ ) / 3600000); // hours
  18.             let diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes
  19.            
  20.             return ((diffHrs >= 10 ? diffHrs + "" : "0" + diffHrs) + ":" + (diffMins !== 0 ? diffMins : "00") + " hs");
  21.             } else if (TurnNo === 0) {
  22.                 return "Descargando";
  23.             } else {
  24.                 return "Descargó";
  25.             }
  26.         },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement