<commit_before>/**
 * @author    : <NAME>
 * @version   : 5.0.0
 * @copyright : 2019
 * @license   : MIT
 */

import { format, formatDistance, formatDistanceStrict, isValid, parseISO, toDate } from "date-fns";
import kramed from "kramed";
import numeral from "numeral";

export namespace UIFormat {
  export function toHTML(md): string {
    return kramed(md, {
      gfm: true,
      tables: true,
      breaks: true,
      pedantic: false,
      sanitize: false,
      smartLists: true,
      smartypants: false
    }).replace(/(<a href=)/gi, '<a class="ui-link" target="_blank" href=');
  }

  // Dates
  function parseDate(dt: string | Date) {
    return typeof dt === "string" ? parseISO(dt) : dt;
  }

  export function date(dt: AnyObject, ft: string = "dd MMM yyyy"): string {
    dt = parseDate(dt);
    return !dt || !isValid(dt) ? null : format(dt, ft, { awareOfUnicodeTokens: true });
  }

  export function time(dt: AnyObject, ft: string = "hh:mm a"): string {
    dt = parseDate(dt);
    return !dt || !isValid(dt) ? null : format(dt, ft, { awareOfUnicodeTokens: true });
  }

  export function datetime(dt: AnyObject, ft: string = "dd MMM yyyy hh:mm a"): string {
    dt = parseDate(dt);
    return !dt || !isValid(dt) ? null : format(dt, ft, { awareOfUnicodeTokens: true });
  }

  export function utcDate(dt): string {
    dt = parseDate(dt);
    return !dt || !isValid(dt) ? null : toDate(dt).toISOString();
  }

  export function dateToISO(dt): string {
    dt = parseDate(dt);
    return !dt || !isValid(dt)
      ? null
      : format(dt, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", {
          awareOfUnicodeTokens: true
        });<commit_msg>Updated date-fns unicode token options<commit_after>/**
 * @author    : <NAME>
 * @version   : 5.0.0
 * @copyright : 2019
 * @license   : MIT
 */

import { format, formatDistance, formatDistanceStrict, isValid, parseISO, toDate } from "date-fns";
import kramed from "kramed";
import numeral from "numeral";

export namespace UIFormat {
  export function toHTML(md): string {
    return kramed(md, {
      gfm: true,
      tables: true,
      breaks: true,
      pedantic: false,
      sanitize: false,
      smartLists: true,
      smartypants: false
    }).replace(/(<a href=)/gi, '<a class="ui-link" target="_blank" href=');
  }

  // Dates
  function parseDate(dt: string | Date) {
    return typeof dt === "string" ? parseISO(dt) : dt;
  }

  export function date(dt: AnyObject, ft: string = "dd MMM yyyy"): string {
    dt = parseDate(dt);
    return !dt || !isValid(dt)
      ? null
      : format(dt, ft, { useAdditionalDayOfYearTokens: true, useAdditionalWeekYearTokens: true });
  }

  export function time(dt: AnyObject, ft: string = "hh:mm a"): string {
    dt = parseDate(dt);
    return !dt || !isValid(dt)
      ? null
      : format(dt, ft, { useAdditionalDayOfYearTokens: true, useAdditionalWeekYearTokens: true });
  }

  export function datetime(dt: AnyObject, ft: string = "dd MMM yyyy hh:mm a"): string {
    dt = parseDate(dt);
    return !dt || !isValid(dt)
      ? null
      : format(dt, ft, { useAdditionalDayOfYearTokens: true, useAdditionalWeekYearTokens: true });
  }

  export function utcDate(dt): string {
    dt = parseDate(dt);
    return !dt || !isValid(dt) ? null : toDate(dt).toISOString();
  }

  export function dateToISO(dt): string {
    dt = parseDate(dt);
    return !dt || !isValid(dt)
      ? null
      : format(dt, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", {
          useAdditionalDayOfYearTokens: true,
          useAdditionalWeekYearTokens: true
        });
{'fraction_non_alphanumeric': 0.14792899408284024, 'fraction_numerical': 0.0039447731755424065, 'mean_word_length': 3.127906976744186, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '1513871', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1215, 'n_words': 316}