<commit_before>(ns frontend.datetime
  (:require [frontend.utils :as utils :include-macros true]
            [cljs-time.coerce :refer [from-long]]
            [cljs-time.format :as time-format]
            [goog.string :as g-string]
            goog.string.format
            [goog.date.DateTime]
            [goog.i18n.DateTimeFormat.Format :as date-formats]))

(defn now []
  (.getTime (js/Date.)))

(defn unix-timestamp []
  (int (/ (now) 1000)))

(def server-offset (atom nil))

(defn update-server-offset [date-header]
  (let [server-date (.fromRfc822String goog.date.DateTime date-header)
        newval (- (.getTime server-date) (now))]
    (swap! server-offset
           (fn [oldval]
             (if oldval
               (min oldval newval)
               newval)))))

(defn server-now []
  (+ (now) (or @server-offset 0)))


(def full-date-format
  (goog.i18n.DateTimeFormat. date-formats/FULL_DATE))

(def full-datetime-format
  (goog.i18n.DateTimeFormat. date-formats/FULL_DATETIME))

(def full-time-format
  (goog.i18n.DateTimeFormat. date-formats/FULL_TIME))

(def long-date-format
  (goog.i18n.DateTimeFormat. date-formats/LONG_DATE))<commit_msg>make update-server-offset robust to parse errors<commit_after>(ns frontend.datetime
  (:require [frontend.utils :as utils :include-macros true]
            [cljs-time.coerce :refer [from-long]]
            [cljs-time.format :as time-format]
            [goog.string :as g-string]
            goog.string.format
            [goog.date.DateTime]
            [goog.i18n.DateTimeFormat.Format :as date-formats]))

(defn now []
  (.getTime (js/Date.)))

(defn unix-timestamp []
  (int (/ (now) 1000)))

(def server-offset (atom nil))

(defn update-server-offset [date-header]
  (when-let [server-date (.fromRfc822String goog.date.DateTime date-header)]
    (let [newval (- (.getTime server-date) (now))]
      (swap! server-offset
             (fn [oldval]
               (if oldval
                 (min oldval newval)
                 newval))))))

(defn server-now []
  (+ (now) (or @server-offset 0)))


(def full-date-format
  (goog.i18n.DateTimeFormat. date-formats/FULL_DATE))

(def full-datetime-format
  (goog.i18n.DateTimeFormat. date-formats/FULL_DATETIME))

(def full-time-format
  (goog.i18n.DateTimeFormat. date-formats/FULL_TIME))

(def long-date-format
  (goog.i18n.DateTimeFormat. date-formats/LONG_DATE))
{'fraction_non_alphanumeric': 0.14747899159663866, 'fraction_numerical': 0.015126050420168067, 'mean_word_length': 2.663076923076923, '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': '2207607', 'n_tokens_mistral': 861, 'n_tokens_neox': 814, 'n_words': 163}