Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3/4課題 #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.github.tanacasino.study.onozawa

import org.joda.time.DateTime

/**
* Created by kohsaku.onozawa on 15/03/04.
*/
object Inplicit {
def main(args: Array[String]) {
implicit class RichInt(val value: Int) {
def day: String = {
"d" + value.toString
}
}
implicit class RichDateTime(val value: DateTime) {
def +(t: String): DateTime = {
t match {
case s if s.startsWith("d") => value.plusDays(t.substring(1).toInt)
case s => new DateTime
}
}
}
val now = new DateTime
println(now)
val tomorrow = now + 1.day
println(tomorrow)
}
}