<commit_before>package mesosphere.marathon.state

import org.joda.time.{ DateTime, DateTimeZone }
import scala.math.Ordered

/**
  * An ordered wrapper for UTC timestamps.
  */
case class Timestamp(dateTime: DateTime) extends Ordered[Timestamp] {

  val time = dateTime.toDateTime(DateTimeZone.UTC)

  override def equals(obj: Any): Boolean = obj match {
    case that: Timestamp => this.time == that.time
    case _               => false
  }

  override def hashCode: Int = time.hashCode

  def compare(that: Timestamp): Int = this.time compareTo that.time

  override def toString: String = time.toString
}

object Timestamp {

  /**
    * Returns a new Timestamp representing the instant that is the supplied
    * number of milliseconds after the epoch.
    */
  def apply(ms: Long): Timestamp = Timestamp(new DateTime(ms))

  /**
    * Returns a new Timestamp representing the supplied time.
    *
    * See the Joda time documentation for a description of acceptable formats:
    * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTimeParser()
    */
  def apply(time: String): Timestamp = Timestamp(DateTime.parse(time))

  /**
    * Returns a new Timestamp representing the current instant.
    */
  def now(): Timestamp = Timestamp(System.currentTimeMillis)

}
<commit_msg>Add comment that Timestamp.hashCode has to use the UTC timestamp<commit_after>package mesosphere.marathon.state

import org.joda.time.{ DateTime, DateTimeZone }
import scala.math.Ordered

/**
  * An ordered wrapper for UTC timestamps.
  */
case class Timestamp(dateTime: DateTime) extends Ordered[Timestamp] {

  val time = dateTime.toDateTime(DateTimeZone.UTC)

  override def equals(obj: Any): Boolean = obj match {
    case that: Timestamp => this.time == that.time
    case _               => false
  }

  /** hashCode must be computed on the UTC timestamp in order to uphold
    * the equals/hashCode contract, 
    * compare java.org.joda.time.base.AbstractInstant.hashCode
    */
  override def hashCode: Int = time.hashCode

  def compare(that: Timestamp): Int = this.time compareTo that.time

  override def toString: String = time.toString
}

object Timestamp {

  /**
    * Returns a new Timestamp representing the instant that is the supplied
    * number of milliseconds after the epoch.
    */
  def apply(ms: Long): Timestamp = Timestamp(new DateTime(ms))

  /**
    * Returns a new Timestamp representing the supplied time.
    *
    * See the Joda time documentation for a description of acceptable formats:
    * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTimeParser()
    */
  def apply(time: String): Timestamp = Timestamp(DateTime.parse(time))

  /**
    * Returns a new Timestamp representing the current instant.
    */
  def now(): Timestamp = Timestamp(System.currentTimeMillis)

}

{'fraction_non_alphanumeric': 0.09666203059805285, 'fraction_numerical': 0.0, 'mean_word_length': 3.467391304347826, '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': '6537824', 'n_tokens_mistral': 840, 'n_tokens_neox': 815, 'n_words': 258}