Skip to content

Commit 110e9ea

Browse files
committed
FIX: none instead of error for an out-of-range ordinal date! selector
related to: Oldes/Rebol-issues#742 Oldes/Rebol-issues#1375
1 parent 0f4436c commit 110e9ea

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/core/t-date.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,10 @@
534534
sym = SYM_YEAR + Int32(arg) - 1;
535535
}
536536

537-
if (sym < SYM_YEAR || sym > SYM_JULIAN)
538-
return PE_BAD_SELECT;
537+
if (sym < SYM_YEAR || sym > SYM_JULIAN) {
538+
//@@ https://github.com/Oldes/Rebol-issues/issues/1375
539+
return (val) ? PE_BAD_SELECT : PE_NONE;
540+
}
539541

540542
if (sym == SYM_TIMEZONE) {
541543
asTimezone = TRUE;

src/tests/units/date-test.r3

+14-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ Rebol [
110110
--assert d/time = 0:10
111111
--assert d/date = 1-Jan-2000
112112

113+
--test-- "issue 1375"
114+
;@@ https://github.com/Oldes/Rebol-issues/issues/1375
115+
; none instead of error for an out-of-range ordinal selector
116+
d: now
117+
--assert none? try [d/0]
118+
--assert none? try [d/-1]
119+
--assert none? try [d/100]
120+
; consistent with time:
121+
t: now/time
122+
--assert none? try [t/0]
123+
--assert none? try [t/-1]
124+
--assert none? try [t/100]
125+
113126
===end-group===
114127

115128
===start-group=== "DATE/TIMEZONE"
@@ -170,7 +183,7 @@ Rebol [
170183
--test-- "query/mode date"
171184
date: 8-Apr-2020 ; no time!
172185
--assert equal? query/mode date all-date-words [2020 4 8 #[none] 2020-04-08 #[none] #[none] #[none] #[none] 3 99 #[none] 2020-04-08 99]
173-
186+
174187
===end-group===
175188

176189

0 commit comments

Comments
 (0)