Skip to content

Instantly share code, notes, and snippets.

@ryanpbrewster
Created May 10, 2016 00:59
Show Gist options
  • Select an option

  • Save ryanpbrewster/4ce3ee51dd87568e49b2fd7f6051ad5d to your computer and use it in GitHub Desktop.

Select an option

Save ryanpbrewster/4ce3ee51dd87568e49b2fd7f6051ad5d to your computer and use it in GitHub Desktop.
@json case class SlackTimestamp(value: String) extends Ordered[SlackTimestamp] { // channel-specific timestamp
def compare(that: SlackTimestamp) = value compare that.value
def toDateTime: DateTime = Try {
// "The bit before the . is a unix timestamp, the bit after is a sequence to guarantee uniqueness."
new DateTime(value.split('.').head.toLong * 1000)
}.getOrElse(throw new Exception(s"Could not parse a date-time out of $value"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment