[m-rev.] diff: implement time.c_gmtime for Erlang backend

Peter Wang wangp at students.csse.unimelb.edu.au
Mon Aug 13 13:06:43 AEST 2007


Estimated hours taken: 0.2
Branches: main

library/time.m:
	Implement time.c_gmtime for Erlang backend.


Index: library/time.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/time.m,v
retrieving revision 1.59
diff -u -r1.59 time.m
--- library/time.m	3 Aug 2007 02:30:40 -0000	1.59
+++ library/time.m	13 Aug 2007 03:03:56 -0000
@@ -735,6 +735,23 @@
 
     N = 0;
 ").
+:- pragma foreign_proc("Erlang",
+    time.c_gmtime(Time::in, Yr::out, Mnt::out, MD::out, Hrs::out,
+        Min::out, Sec::out, YD::out, WD::out, N::out),
+    [will_not_call_mercury, promise_pure],
+"
+    {{Yr0, Mnt, MD}, {Hrs, Min, Sec}} = Time,
+    Yr = Yr0 - 1900,
+
+    DayNumber = calendar:date_to_gregorian_days(Yr, Mnt, MD),
+    Jan1_Number = calendar:date_to_gregorian_days(Yr, 1, 1),
+    YD = DayNumber - Jan1_Number,
+
+    % Sunday = 7 = 0
+    WD = calendar:day_of_the_week(Yr, Mnt, MD) rem 7,
+
+    N = 0
+").
 
 :- func int_to_maybe_dst(int) = maybe(dst).
 
--------------------------------------------------------------------------
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