aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStewart Stewart <stewinsalot@gmail.com>2016-12-19 21:40:02 -0500
committerStewart Stewart <stewinsalot@gmail.com>2016-12-19 21:40:02 -0500
commitd514c186b505257fbfd631d5a4b707150aa78b7e (patch)
tree15da821a28f1fa5a5cf688e9980880a6dac6c481
parent0ce42d864b4d79902bb661743682c913faae0df0 (diff)
downloaddriver-core-d514c186b505257fbfd631d5a4b707150aa78b7e.tar.gz
driver-core-d514c186b505257fbfd631d5a4b707150aa78b7e.tar.bz2
driver-core-d514c186b505257fbfd631d5a4b707150aa78b7e.zip
add json formatter for date
-rw-r--r--src/main/scala/xyz/driver/core/json.scala6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/scala/xyz/driver/core/json.scala b/src/main/scala/xyz/driver/core/json.scala
index a3894db..4007e78 100644
--- a/src/main/scala/xyz/driver/core/json.scala
+++ b/src/main/scala/xyz/driver/core/json.scala
@@ -7,12 +7,14 @@ import akka.http.scaladsl.unmarshalling.Unmarshaller
import spray.json.{DeserializationException, JsNumber, _}
import xyz.driver.core.revision.Revision
import xyz.driver.core.time.Time
-import xyz.driver.core.date.Month
+import xyz.driver.core.date.{Date, Month}
import scala.reflect.runtime.universe._
object json {
+ import DefaultJsonProtocol._
+
def IdInPath[T]: PathMatcher1[Id[T]] = new PathMatcher1[Id[T]] {
def apply(path: Path) = path match {
case Path.Segment(segment, tail) => Matched(tail, Tuple1(Id[T](segment)))
@@ -75,6 +77,8 @@ object json {
}
}
+ implicit val dateFormat = jsonFormat3(Date)
+
def RevisionInPath[T]: PathMatcher1[Revision[T]] =
PathMatcher("""[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}""".r) flatMap { string =>
Some(Revision[T](string))