Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/datetime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ uint to_date(object_p dtobj, dt_t &dt, tm_t &tm, bool error)

const uint days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
bool bisext = m == 2 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
if (m < 1 || m > 12 || d < 1 || d > days[m-1] + bisext || y == 0)
Comment thread
evgaster marked this conversation as resolved.
if (m < 1 || m > 12 || d < 1 || d > days[m-1] + bisext)
{
if (error)
rt.invalid_date_error();
Expand Down Expand Up @@ -624,11 +624,6 @@ size_t render_date(renderer &r, algebraic_g date)
uint month = date->as_uint32(0, false) % 100;
date = date / factor;
uint year = date->as_uint32(0, false);
if (year == 0)
{
rt.invalid_date_error();
return 0;
}

char mname[4];
if (Settings.ShowMonthName() && month >=1 && month <= 12)
Expand Down Expand Up @@ -660,7 +655,7 @@ size_t render_date(renderer &r, algebraic_g date)
case 3: r.printf("%s%c%s%c%u", ytext, sep, mname, sep, day); break;
}
if (neg)
r.printf(" BC");
r.printf(" BCE");
Comment thread
evgaster marked this conversation as resolved.
Outdated

if (time && !time->is_zero())
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10134,7 +10134,7 @@ void tests::date_operations()
.expect("2 460 938");
step("Converting from a Julian day number to a date")
.test(CLEAR, "1 000 000", ENTER, ID_DateFromJulianDayNumber)
.expect("Tue 21/Oct/1975 BC");
.expect("Tue 21/Oct/1975 BCE");
step("Adding invalid dates")
.test(CLEAR, "1 2 DATE+", ENTER)
.error("Invalid date");
Expand Down