Skip to content

Commit b18dc57

Browse files
committed
FEAT: to-date mezzanine function accepting input in format like: 1-1-2000 00:00:00
resolves: Oldes/Rebol-issues#1362
1 parent 44e7f80 commit b18dc57

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/mezz/mezz-date.reb

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ to-date: function/with [
6464
copy time: to sp sp
6565
[copy zone: [plus-minus 4 numeric] | no-case "GMT" (zone: "+0")]
6666
to end ; ignore the rest (like comments in mime fields)!
67+
|
68+
copy day: 1 2 numeric #"-"
69+
copy month: 1 2 numeric #"-"
70+
copy year: 1 4 numeric sp
71+
copy time: [1 2 numeric #":" 1 2 numeric opt [#":" 1 2 numeric]]
72+
to end
6773
]
6874
][
6975
value: to string! rejoin [day "-" month "-" year "/" time any [zone ""]]

src/tests/units/date-test.r3

+4-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,10 @@ Rebol [
328328
--assert 4-Apr-2019/19:41:46 = to-date "Thu, 04 Apr 2019 19:41:46 GMT"
329329
--assert 1-Apr-2019/21:50:04 = to-date "Mon, 1 Apr 2019 21:50:04 GMT"
330330
--assert 30-Jul-2013/2:17:58-7:00 = to-date "Tue, 30 Jul 2013 02:17:58 -0700 (PDT)"
331-
331+
--test-- "TO-DATE {1-1-2000 00:00:00}"
332+
;@@ https://github.com/Oldes/Rebol-issues/issues/1362
333+
--assert 1-Jan-2000/0:00 == to-date "1-1-2000 00:00:00"
334+
--assert 1-Jan-2000/0:00 == to-date "1-1-2000 00:00"
332335

333336
===end-group===
334337

0 commit comments

Comments
 (0)