<commit_before>import str from '../src/jsturbo-string'

function toStringDMY (date) {
  return [
    str.pad(date.getDate().toString(), 2),
    str.pad((date.getMonth() + 1).toString(), 2),
    str.pad(date.getFullYear().toString(), 4)
  ].join('/')
};

function isToday (date) {
  return toStringDMY(date) === toStringDMY(new Date())
};

function fromStringDMY (stringDdMmYyyy) {
  stringDdMmYyyy = stringDdMmYyyy.replace(/\D/g, '')
  var day = parseInt(stringDdMmYyyy.substr(0, 2))
  var month = parseInt(stringDdMmYyyy.substr(2, 2)) - 1
  var year = parseInt(stringDdMmYyyy.substr(4, 4))
  return new Date(year, month, day, 0, 0, 0, 0)
};

const mainExport = {
  toStringDMY: toStringDMY,
  isToday: isToday,
  fromStringDMY: fromStringDMY
}

export default mainExport
module.exports = mainExport // for CommonJS compatibility<commit_msg>docs(date): Add documentation to the date module<commit_after>import str from '../src/jsturbo-string'

/**
 * Converts a date to string in the format 'dd/MM/yyyy'
 * @param  {Date} Date object
 * @return {string}
 */
function toStringDMY (date) {
  return [
    str.pad(date.getDate().toString(), 2),
    str.pad((date.getMonth() + 1).toString(), 2),
    str.pad(date.getFullYear().toString(), 4)
  ].join('/')
};

/**
 * Check if a date object represents the current day
 * @param  {Date}
 * @return {Boolean}
 */
function isToday (date) {
  return toStringDMY(date) === toStringDMY(new Date())
};

/**
 * Create a Date object based on a string in the format 'dd/MM/yyyy'
 * @param  {string} string with a date in the format 'dd/MM/yyyy'
 * @return {Date}
 */
function fromStringDMY (stringDdMmYyyy) {
  stringDdMmYyyy = stringDdMmYyyy.replace(/\D/g, '')
  var day = parseInt(stringDdMmYyyy.substr(0, 2))
  var month = parseInt(stringDdMmYyyy.substr(2, 2)) - 1
  var year = parseInt(stringDdMmYyyy.substr(4, 4))
  return new Date(year, month, day, 0, 0, 0, 0)
};

const mainExport = {
  toStringDMY: toStringDMY,
  isToday: isToday,
  fromStringDMY: fromStringDMY
}

export default mainExport
module.exports = mainExport // for CommonJS compatibility
{'fraction_non_alphanumeric': 0.1505736137667304, 'fraction_numerical': 0.014340344168260038, 'mean_word_length': 4.193548387096774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2535175', 'n_tokens_mistral': 789, 'n_tokens_neox': 757, 'n_words': 189}