All files / utils dateUtils.js

100% Statements 11/11
100% Branches 2/2
100% Functions 3/3
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  25x   4x 10x 10x       4x 72x 72x 72x 72x 72x      
 
const padWithZero = (n) => { return n < 10 ? '0' + n : n; }
 
const timestampToDate = (timestamp) => {
    var date = new Date(timestamp);
    return (date.getFullYear() + "-" + (padWithZero(date.getMonth()+1)) + "-" + padWithZero(date.getDate()));
}
 
 
const calculateDays = (startingDate,currentDate) => {
    const start = new Date(startingDate);
    const today = new Date(currentDate);
    const timeDifference = today.getTime() - start.getTime();
    const days = Math.floor(timeDifference / (1000 * 3600 * 24))+1;
    return days;
  }
 
export {timestampToDate, padWithZero, calculateDays};