[m-rev.] Re: for review: new calendar standard library module
Ian MacLarty
maclarty at csse.unimelb.edu.au
Mon Feb 2 14:39:41 AEDT 2009
On Mon, Feb 02, 2009 at 01:26:02PM +1100, Ian MacLarty wrote:
> Here is a new version of the calendar module for review.
>
I noticed a couple of bugs while looking though the code. I also fixed
a typo in the comments for int.div. Here's an interdiff.
diff -u library/calendar.m library/calendar.m
--- library/calendar.m 2 Feb 2009 02:21:57 -0000
+++ library/calendar.m 2 Feb 2009 03:01:07 -0000
@@ -324,7 +324,6 @@
read_int_and_num_chars(Year, YearChars, !Chars)
),
YearChars >= 4,
- Year \= 0,
read_char((-), !Chars),
read_int_and_num_chars(Month, 2, !Chars),
Month >= 1,
@@ -937,11 +936,11 @@
:- func julian_day(int, int, int) = int.
julian_day(Year, Month, Day) = JDN :-
- A = (14 - Month) // 12,
+ A = (14 - Month) div 12,
Y = Year + 4800 - A,
M = Month + 12 * A - 3,
- JDN = Day + ( 153 * M + 2 ) // 5 + 365 * Y + Y // 4 - Y // 100 + Y // 400
- - 32045.
+ JDN = Day + ( 153 * M + 2 ) div 5 + 365 * Y + Y div 4 - Y div 100 +
+ Y div 400 - 32045.
:- func det_day_of_week_from_mod(int) = day_of_week.
diff -u tests/hard_coded/calendar_test.exp tests/hard_coded/calendar_test.exp
--- tests/hard_coded/calendar_test.exp 2 Feb 2009 01:18:12 -0000
+++ tests/hard_coded/calendar_test.exp 2 Feb 2009 03:01:35 -0000
@@ -95,6 +95,10 @@
1865-02-27 00:00:00 : monday
1886-02-08 00:00:00 : monday
1929-10-28 00:00:00 : monday
+0000-12-31 00:00:00 : sunday
+0001-01-01 00:00:00 : monday
+-0001-12-31 00:00:00 : friday
+0000-01-01 00:00:00 : saturday
Parse test:
P2Y6M100DT10H16M30.0003S
diff -u tests/hard_coded/calendar_test.m tests/hard_coded/calendar_test.m
--- tests/hard_coded/calendar_test.m 2 Feb 2009 01:16:10 -0000
+++ tests/hard_coded/calendar_test.m 2 Feb 2009 02:52:53 -0000
@@ -67,6 +67,10 @@
test_day_of_week("1865-02-27 00:00:00", !IO),
test_day_of_week("1886-02-08 00:00:00", !IO),
test_day_of_week("1929-10-28 00:00:00", !IO),
+ test_day_of_week("0000-12-31 00:00:00", !IO),
+ test_day_of_week("0001-01-01 00:00:00", !IO),
+ test_day_of_week("-0001-12-31 00:00:00", !IO),
+ test_day_of_week("0000-01-01 00:00:00", !IO),
io.nl(!IO),
io.write_string("Parse test:\n", !IO),
io.write_string(duration_to_string(
only in patch2:
unchanged:
--- library/int.m 13 Dec 2008 12:59:02 -0000 1.123
+++ library/int.m 2 Feb 2009 02:43:42 -0000
@@ -102,7 +102,7 @@
:- func int.minus(int, int) = int.
% flooring integer division
- % Truncates towards minus infinity, e.g. (-10) // 3 = (-4).
+ % Truncates towards minus infinity, e.g. (-10) div 3 = (-4).
%
% Throws a `math.domain_error' exception if the right operand
% is zero. See the comments at the top of math.m to find out how to
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list