summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--ext/date/date_core.c15
2 files changed, 11 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index a39ff9be3ee..d8b76ce6176 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Jun 24 00:44:15 2011 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * ext/date/date_core.c (c_valid_{julian,gregorian}_p): fixed the range of month.
+
Fri Jun 24 00:14:23 2011 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/date_core.c: trivial changes on text.
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index e43415923bd..bdb13a87526 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -693,7 +693,7 @@ c_valid_julian_p(int y, int m, int d, int *rm, int *rd)
if (m < 0)
m += 13;
- if (m < 0 || m > 12)
+ if (m < 1 || m > 12)
return 0;
last = c_julian_last_day_of_month(y, m);
if (d < 0)
@@ -712,7 +712,7 @@ c_valid_gregorian_p(int y, int m, int d, int *rm, int *rd)
if (m < 0)
m += 13;
- if (m < 0 || m > 12)
+ if (m < 1 || m > 12)
return 0;
last = c_gregorian_last_day_of_month(y, m);
if (d < 0)
@@ -2114,17 +2114,16 @@ valid_civil_p(VALUE y, int m, int d, double sg,
decode_year(y, ns ? -1 : +1, &nth2, ry);
}
}
- else if (style > 1) {
+ else {
decode_year(y, style, nth, ry);
- r = c_valid_julian_p(*ry, m, d, rm, rd);
+ if (style < 0)
+ r = c_valid_gregorian_p(*ry, m, d, rm, rd);
+ else
+ r = c_valid_julian_p(*ry, m, d, rm, rd);
if (!r)
return 0;
c_civil_to_jd(*ry, *rm, *rd, style, rjd, ns);
}
- else {
- decode_year(y, style, nth, ry);
- r = c_valid_civil_p(*ry, m, d, style, rm, rd, rjd, ns);
- }
return r;
}