Created
July 23, 2009 14:03
-
-
Save chrislewis/152965 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.{Calendar, Date} | |
import Calendar._ | |
class TimeIncrement(val increment: Int /* FIXME */, val amount: Int) | |
class IntDate(val number: Int) { | |
def days = new TimeIncrement(DATE, number) | |
} | |
object IntDate { | |
implicit def int2IntDate(i: Int) = new IntDate(i) | |
} | |
class RichDate(val date: Date) { | |
def > (date: Date) = this.date.after(date) | |
def < (date: Date) = this.date.before(date) | |
def + (ti: TimeIncrement) = { | |
val cal = Calendar.getInstance | |
cal.setTime(date) | |
cal.add(ti.increment, ti.amount) | |
cal.getTime | |
} | |
} | |
object RichDate { | |
implicit def date2RichDate(date: Date) = new RichDate(date) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment