Skip to content

Commit

Permalink
FEAT: to-date mezzanine function accepting input in format like: `1…
Browse files Browse the repository at this point in the history
…-1-2000 00:00:00`

resolves: Oldes/Rebol-issues#1362
  • Loading branch information
Oldes committed Jun 9, 2023
1 parent 44e7f80 commit b18dc57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/mezz/mezz-date.reb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ to-date: function/with [
copy time: to sp sp
[copy zone: [plus-minus 4 numeric] | no-case "GMT" (zone: "+0")]
to end ; ignore the rest (like comments in mime fields)!
|
copy day: 1 2 numeric #"-"
copy month: 1 2 numeric #"-"
copy year: 1 4 numeric sp
copy time: [1 2 numeric #":" 1 2 numeric opt [#":" 1 2 numeric]]
to end
]
][
value: to string! rejoin [day "-" month "-" year "/" time any [zone ""]]
Expand Down
5 changes: 4 additions & 1 deletion src/tests/units/date-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ Rebol [
--assert 4-Apr-2019/19:41:46 = to-date "Thu, 04 Apr 2019 19:41:46 GMT"
--assert 1-Apr-2019/21:50:04 = to-date "Mon, 1 Apr 2019 21:50:04 GMT"
--assert 30-Jul-2013/2:17:58-7:00 = to-date "Tue, 30 Jul 2013 02:17:58 -0700 (PDT)"

--test-- "TO-DATE {1-1-2000 00:00:00}"
;@@ https://github.com/Oldes/Rebol-issues/issues/1362
--assert 1-Jan-2000/0:00 == to-date "1-1-2000 00:00:00"
--assert 1-Jan-2000/0:00 == to-date "1-1-2000 00:00"

===end-group===

Expand Down

0 comments on commit b18dc57

Please sign in to comment.