<commit_before>'use strict';

var _ = require('lodash');
var moment = require('moment');

module.exports = {};

/**
 * @namespace serialize
 */

/**
 * @function iso8601Date
 * @memberOf serialize
 * @description turns a Date object into a string if parameter is a Date
 * otherwise returns the parameter
 *
 * @param  {Date} d date object to format
 * @return {string|object} date formatted in YYYY-MM-DD form
 */
module.exports.iso8601Date = function(d) {
  if (_.isUndefined(d) || _.isString(d) || !((d instanceof Date))) {
    return d;
  } else {
    return moment.utc(d).format('YYYY-MM-DD');
  }
};

/**
 * @function iso8601DateTime
 * @memberOf serialize
 * @description turns a Date object into a string if parameter is a Date
 * otherwise returns the parameter
 *
 * @param  {Date} d date object to format
 * @return {string|object} date formatted in YYYY-MM-DD[T]HH:mm:ss[Z] form
 */<commit_msg>use _.isDate to check if object is a Date object (#335)<commit_after>'use strict';

var _ = require('lodash');
var moment = require('moment');

module.exports = {};

/**
 * @namespace serialize
 */

/**
 * @function iso8601Date
 * @memberOf serialize
 * @description turns a Date object into a string if parameter is a Date
 * otherwise returns the parameter
 *
 * @param  {Date} d date object to format
 * @return {string|object} date formatted in YYYY-MM-DD form
 */
module.exports.iso8601Date = function(d) {
  if (_.isUndefined(d) || _.isString(d) || !(_.isDate(d))) {
    return d;
  } else {
    return moment.utc(d).format('YYYY-MM-DD');
  }
};

/**
 * @function iso8601DateTime
 * @memberOf serialize
 * @description turns a Date object into a string if parameter is a Date
 * otherwise returns the parameter
 *
 * @param  {Date} d date object to format
 * @return {string|object} date formatted in YYYY-MM-DD[T]HH:mm:ss[Z] form
 */
{'fraction_non_alphanumeric': 0.13813651137594798, 'fraction_numerical': 0.014626218851570965, 'mean_word_length': 3.847769028871391, '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': '196780', 'n_tokens_mistral': 615, 'n_tokens_neox': 589, 'n_words': 194}