tuned signature;
authorwenzelm
Wed, 05 Oct 2016 22:07:36 +0200
changeset 64058 f3fa0bb3f666
parent 64057 365d367d2b45
child 64059 1bbea2b55d22
tuned signature;
src/Pure/General/date.scala
--- a/src/Pure/General/date.scala	Wed Oct 05 21:02:08 2016 +0200
+++ b/src/Pure/General/date.scala	Wed Oct 05 22:07:36 2016 +0200
@@ -20,7 +20,7 @@
 
   object Format
   {
-    def make(fmts: List[DateTimeFormatter]): Format =
+    def make(fmts: List[DateTimeFormatter], filter: String => String = s => s): Format =
     {
       require(fmts.nonEmpty)
 
@@ -37,10 +37,13 @@
       new Format {
         def apply(date: Date): String = fmts.head.format(date.rep)
         def parse(str: String): Date =
-          new Date(ZonedDateTime.from(parse_first(None, fmts, str)))
+          new Date(ZonedDateTime.from(parse_first(None, fmts, filter(str))))
       }
     }
 
+    def make_patterns(patterns: List[String], filter: String => String = s => s): Format =
+      make(patterns.toList.map(DateTimeFormatter.ofPattern(_)), filter)
+
     def apply(patterns: String*): Format =
       make(patterns.toList.map(DateTimeFormatter.ofPattern(_)))