summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/date/parse.myr4
-rw-r--r--lib/date/test/parse.myr9
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/date/parse.myr b/lib/date/parse.myr
index 80f0b76..19798dd 100644
--- a/lib/date/parse.myr
+++ b/lib/date/parse.myr
@@ -164,9 +164,9 @@ const eatspace = {s
const indexof = {dst, s, set, err
for var i = 0; i < set.len; i++
- if s.len >= set[i].len && std.streq(s, set[i])
+ if s.len >= set[i].len && std.streq(s[:set[i].len], set[i])
dst# = i
- -> s
+ -> s[set[i].len:]
;;
;;
err# = `std.Some `Badname s
diff --git a/lib/date/test/parse.myr b/lib/date/test/parse.myr
index 6bc7347..a6aef7e 100644
--- a/lib/date/test/parse.myr
+++ b/lib/date/test/parse.myr
@@ -37,6 +37,15 @@ const main = {
| `std.Err m:
std.fatal("Failed to parse date: {}", m)
;;
+
+ /*Names*/
+ match date.parsefmt("%a, %d %b %Y %H:%M:%S %z", "Thu, 21 Sep 2017 13:55:05 -0400")
+ | `std.Ok d:
+ std.assert(d.actual == 1506016505 * 1_000_000, "wrong timestamp")
+ eq(std.bfmt(buf[:], "{D}", d), "2017-9-21 13:55:05 -0400")
+ | `std.Err m:
+ std.fatal("Failed to parse date: {}", m)
+ ;;
}
const eq = {actual, expected