<commit_before>(ns swarmpit.time
  (:require [clojure.contrib.humanize :as humanize]
            [clojure.string :as str]
            [cljs-time.core :refer [after? to-default-time-zone now]]
            [cljs-time.format :as format]))

(def docker-format
  (format/formatters :date-time-no-ms))

(def simple-format
  (format/formatters :mysql))

(defn- trim-ms
  [datetime]
  (str/replace datetime #"\.(.+)(Z|\+.*|-.*)$" "$2"))

(defn parse
  [datetime]
  (->> (trim-ms datetime)
       (format/parse docker-format)))

(defn- shift-future-date
  [date]
  (if (after? date (now))
    (now)
    date))

(defn humanize
  [datetime]
  (->> (parse datetime)
       (shift-future-date)
       (humanize/datetime)))

(defn simplify
  [datetime]
  (->> (parse datetime)
       (to-default-time-zone)
       (format/unparse simple-format)))

(defn valid?<commit_msg>docker time to unix ts support #260<commit_after>(ns swarmpit.time
  (:require [clojure.contrib.humanize :as humanize]
            [cljs-time.coerce :refer [to-epoch]]
            [cljs-time.core :refer [after? to-default-time-zone now minus minutes]]
            [cljs-time.format :as format]
            [clojure.string :as str]))

(def docker-format
  (format/formatters :date-time-no-ms))

(def simple-format
  (format/formatters :mysql))

(defn- trim-ms
  [datetime]
  (str/replace datetime #"\.(.+)(Z|\+.*|-.*)$" "$2"))

(defn parse
  [datetime]
  (->> (trim-ms datetime)
       (format/parse docker-format)))

(defn to-unix
  [datetime]
  (let [dt (parse datetime)]
    (and dt (quot dt 1000))))

(defn to-unix-past
  [minutes-to-history]
  (let [dt (minus
             (now)
             (minutes minutes-to-history))]
    (and dt (quot dt 1000))))

(defn- shift-future-date
  [date]
  (if (after? date (now))
    (now)
    date))

(defn humanize
  [datetime]
  (->> (parse datetime)
       (shift-future-date)
       (humanize/datetime)))

(defn simplify
  [datetime]
  (->> (parse datetime)
       (to-default-time-zone)
       (format/unparse simple-format)))

(defn valid?
{'fraction_non_alphanumeric': 0.1762977473065622, 'fraction_numerical': 0.006366307541625857, 'mean_word_length': 2.687725631768953, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '4597295', 'n_tokens_mistral': 770, 'n_tokens_neox': 741, 'n_words': 166}