Module that extracts date format out of sample of dates
If you have sources of the data with inconsistent date formats, usually it is required to figure out date format of each data set before doing any analysis with the data. This module is trying to solve that issue by extracting date format from the array of the dates. The more elements are in the array, the more accurate is the prediction. 13 consecutive days are enough for accurate prediction of the date format.
This module can detect all official date formats of all the countries represented here https://en.wikipedia.org/wiki/Date_format_by_country
const getDateFormat =// or// import getDateFormat from 'get-date-format'const sampleOfDates = '2017-01-01' '2017-03-11' '2017-03-13' '2017-12-12'const dateFormat =console// YYYY-MM-DD
If date format can't be extracted, function is returning
const getDateFormat =// or// import getDateFormat from 'get-date-format'const sampleOfDates = 'some text' 'more text'const dateFormat =console// null
Optimizing for speed