Created
July 11, 2016 14:13
-
-
Save h0tk3y/adee632e5d21a566e52ba3fdd34a548c to your computer and use it in GitHub Desktop.
This file contains hidden or 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.* | |
| import kotlin.reflect.KMutableProperty1 | |
| fun <T> KMutableProperty1<T, Date>.addDays(receiver: T, nrOfDays: Int) { | |
| val cal = Calendar.getInstance() | |
| cal.time = this.get(receiver) | |
| cal.add(Calendar.DAY_OF_YEAR, nrOfDays) | |
| this.set(receiver, cal.time) | |
| } | |
| class C(var date: Date) | |
| fun main(args: Array<String>) { | |
| val c = C(Date(0)) | |
| C::date.addDays(c, 123) | |
| println(c.date) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment