Description

Twigkit service for useful date functions

Methods

  • dateSortResults(results, dateField, oldestFirst)

    Sort results array by date

    Parameters
    ParamTypeDetails
    resultsmixed

    Array of results from response

    dateFieldstring

    Result field to use for ordering

    oldestFirstboolean

    If true the results will be order from oldest to newest

    Returns
    mixed

    Sorted array of results

  • groupByDateRanges(results, dateField, groupBy)

    Group results into date ranges, used for the timeline

    Parameters
    ParamTypeDetails
    resultsmixed

    Sorted array of results

    dateFieldstring

    Result field to use for ordering

    groupBystring

    Optionally specify how to group the results, by default it tries to get the best fit

    Returns
    mixed

    Array of grouped results