Skip to content

Instantly share code, notes, and snippets.

@jamesgolick
Created November 23, 2009 22:30
Show Gist options
  • Select an option

  • Save jamesgolick/241443 to your computer and use it in GitHub Desktop.

Select an option

Save jamesgolick/241443 to your computer and use it in GitHub Desktop.
import java.util.Date
object FancyInt {
implicit def int2FancyInt(int: Int): FancyInt = new FancyInt(int)
}
class FancyInt(val integer: Int) {
def day: Int = integer * 86400
def days: Int = day
def hour: Int = integer * 3600
def hours: Int = hour
def minute: Int = integer * 60
def minutes: Int = minute
def ago: Date = new Date(System.currentTimeMillis() - integer * 1000)
}
// vim: set ts=4 sw=4 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment