[m-rev.] for review: implement io__file_modification_time_2 in C#

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Nov 1 16:17:49 AEDT 2003


On 31-Oct-2003, Peter Ross <pro at missioncriticalit.com> wrote:
[relative diff]

That is better, but there were still a few problems remaining.
I have committed the following patch.

----------

Estimated hours taken: 1
Branches: main

Some fixes for the C# implementation of time.m.

library/time.m:
	Implement time__clk_tck in C#.

	Fix a bug in the C# implementation of time__mktime:
	the argument is expressed in local time, not UTC,
	so we need to convert it to UTC.

	Add an XXX comment about a bug in the C# version of time__c_localtime.
	There does not seem to be any easy way of fixing this bug --
	the .NET API doesn't provide any way to get it right.

	Replace an XXX comment about a potentially unsafe cast with a comment
	explaining why the cast is safe.

	Wrap a long line.

Workspace: /home/ceres/fjh/mercury
Index: library/time.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/time.m,v
retrieving revision 1.36
diff -u -d -r1.36 time.m
--- library/time.m	31 Oct 2003 22:13:21 -0000	1.36
+++ library/time.m	1 Nov 2003 05:16:25 -0000
@@ -248,7 +248,8 @@
 	[will_not_call_mercury, promise_pure, tabled_for_io],
 "{
 	// XXX Ticks is long in .NET!
-	Ret = (int) System.Diagnostics.Process.GetCurrentProcess.UserProcessorTime.Ticks;
+	Ret = (int) System.Diagnostics.Process.GetCurrentProcess
+		.UserProcessorTime.Ticks;
 }").
 */
 
@@ -270,7 +271,7 @@
 :- pragma foreign_proc("C#", time__c_clocks_per_sec(Ret::out),
 	[will_not_call_mercury, promise_pure],
 "{
-	// XXX TicksPerSecond is long in .NET!
+	// TicksPerSecond is guaranteed to be 10,000,000
 	Ret = (int) System.TimeSpan.TicksPerSecond;
 }").
 
@@ -338,6 +339,12 @@
 	Ret = -1;
 #endif
 }").
+:- pragma foreign_proc("C#", time__clk_tck = (Ret::out),
+	[will_not_call_mercury, promise_pure],
+"{
+	// TicksPerSecond is guaranteed to be 10,000,000
+	Ret = (int) System.TimeSpan.TicksPerSecond;
+}").
 
 %-----------------------------------------------------------------------------%
 
@@ -465,6 +472,11 @@
 	WD = (int) t.DayOfWeek;
 	MD = t.Day;
 	YD = t.DayOfYear - 1;
+	// XXX On the day when you switch back to standard time from daylight
+	// savings time, the time '2:30am' occurs twice, once during daylight
+	// savings time (N = 1), and then again an hour later, during standard
+	// time (N = 0).  The .NET API does not seem to provide any way to
+	// get the right answer in both cases.
 	if (System.TimeZone.CurrentTimeZone.IsDaylightSavingTime(t)) {
 		N = 1;
 	} else {
@@ -580,8 +592,11 @@
 	// On the day when you switch back to standard time from daylight
 	// savings time, the time '2:30am' occurs twice, once during daylight
 	// savings time (N = 1), and then again an hour later, during standard
-	// time (N = 0).
- 	Time = new System.DateTime(Yr + 1900, Mnt + 1, MD, Hrs, Min, Sec);
+	// time (N = 0).  The .NET API does not seem to provide any way to
+	// get the right answer in both cases.
+	System.DateTime local_time = 
+		new System.DateTime(Yr + 1900, Mnt + 1, MD, Hrs, Min, Sec);
+	Time = local_time.ToUniversalTime();
 }").
 
 :- func maybe_dst_to_int(maybe(dst)) = int.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list