<commit_before>package shared.utils

import cats.syntax.either._
import io.circe.{Decoder, Encoder}
import org.threeten.bp.OffsetDateTime

/**
  * Created by alexe on 18.01.2017.
  */
trait Codecs {
  implicit val encodeOffsetDateTime: Encoder[OffsetDateTime] = Encoder.encodeString.contramap[OffsetDateTime](_.toString())

  implicit val decodeOffsetDateTime: Decoder[OffsetDateTime] = Decoder.decodeString.emap { str =>
    val offsetDateTime = OffsetDateTime.parse(str)

    Either.catchNonFatal(offsetDateTime).leftMap(_.getMessage)
  }
}<commit_msg>better/more codecs<commit_after>package shared.utils

import cats.syntax.either._
import io.circe.{Decoder, Encoder}
import org.threeten.bp.{LocalDate, LocalDateTime, LocalTime, OffsetDateTime}

/**
  * Created by alexe on 18.01.2017.
  */
trait Codecs {

  def createSimpleCodec[T](encode: T => String, decode: String => T): (Encoder[T], Decoder[T]) =
    (Encoder.encodeString.contramap[T](encode),
      Decoder.decodeString.emap(str => Either.catchNonFatal(decode(str)).leftMap(_.getMessage)))

  implicit val (encodeOffsetDateTime, decodeOffsetDateTime) = createSimpleCodec[OffsetDateTime](_.toString(), OffsetDateTime.parse)
  implicit val (encodeLocalDateTime, decodeLocalDateTime) = createSimpleCodec[LocalDateTime](_.toString(), LocalDateTime.parse)
  implicit val (encodeLocalDate, decodeLocalDate) = createSimpleCodec[LocalDate](_.toString(), LocalDate.parse)
  implicit val (encodeLocalTime, decodeLocalTime) = createSimpleCodec[LocalTime](_.toString(), LocalTime.parse)
}
{'fraction_non_alphanumeric': 0.1222366710013004, 'fraction_numerical': 0.010403120936280884, 'mean_word_length': 6.225352112676056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1362477', 'n_tokens_mistral': 473, 'n_tokens_neox': 459, 'n_words': 87}