# All files / src/lib/nunjucks-extensions nunjucks-date.ts

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
100% Lines 5/5

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
    179x

    9x

    16x

    9x
    16x

     import Moment from 'moment';

    const DEFAULT_FORMAT = 'ddd D MMM'; // e.g. Thu 27 Aug

    /**
     * Calculates the result of adding {days} days to the base date
     * @param base
     * @param days
     */
    function calculateTarget(base: string, days: number) {
      return Moment(base).add(days, 'days');
    }

    export function filter(baseDate: string, format = DEFAULT_FORMAT, day = 0) {
      return calculateTarget(baseDate, day).format(format);
    }