<commit_before>defmodule WebbkollWeb.SiteView do
  use WebbkollWeb, :view

  def format_timestamp(nil) do
    "session"
  end

  def format_timestamp(time) do
    time
    |> Kernel.round()
    |> DateTime.from_unix!()
    |> DateTime.to_string()
  end<commit_msg>Gracefully handle timestamps outside the range of DateTime<commit_after>defmodule WebbkollWeb.SiteView do
  use WebbkollWeb, :view

  def format_timestamp(nil) do
    "session"
  end

  def format_timestamp(time) do
    time = if time > 253_402_300_799, do: 253_402_300_799, else: time

    case DateTime.from_unix(Kernel.round(time)) do
      {:ok, datetime} -> DateTime.to_string(datetime)
      {:error, _} -> "invalid"
    end
  end
{'fraction_non_alphanumeric': 0.09857142857142857, 'fraction_numerical': 0.03428571428571429, 'mean_word_length': 3.7364864864864864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2630120', 'n_tokens_mistral': 268, 'n_tokens_neox': 239, 'n_words': 57}