Note that there are some explanatory texts on larger screens.

plurals
  1. PODateTime.ToString in Mono return invalid date ("00/734718/0001 01:41:38")
    primarykey
    data
    text
    <p>I am trying to get mono (Debian 2.10.8.1-5) to run properly on my raspberry pi with the raspbian distro ("Debian GNU/Linux wheezy/sid"). I have installed mono with apt-get install mono-complete.</p> <p>However, I am running into an interesting issue that I cannot figure out. The DateTime.ToString() method returns an invalid string.</p> <p>Below you can find my sample program with the console output:</p> <pre><code>using System; namespace MonoTest { class Program { static void Main(string[] args) { DateTime now = DateTime.Now; Console.WriteLine("Year: " + now.Year); Console.WriteLine("Month: " + now.Month); Console.WriteLine("Day: " + now.Day); Console.WriteLine("DayOfWeek: " + now.DayOfWeek); Console.WriteLine("DateTime.Now: " + DateTime.Now); Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd")); } } } </code></pre> <p>Output:</p> <pre><code>pi@raspberrypi ~/bin $ mono MonoTest.exe Year: 2012 Month: 8 Day: 3 DayOfWeek: Friday DateTime.Now: 00/734718/0001 01:41:38 0001-00-734718 </code></pre> <p>Interestingly enough, 734718 seems to be the the number of days elapsed till today since 01/01/0001. I have tryed it with a fresh installation on a second board but with the same issue.</p> <p>Does anyone have an idea what the problem here is and how to convince DateTime.ToString() to return the right value?</p> <p><strong>Update (8/4/2012):</strong> After long digging through the mono source code I was able to trace the issue back to System.Math.Floor. Apparently, it always returns 0. I changed my test program to a simple:</p> <pre><code>static void Main(string[] args) { Console.WriteLine("Floor(1.5): " + System.Math.Floor(1.5)); } </code></pre> <p>On Windows the result is "Floor(1.5): 1" Whereas on my mono setup on the raspberry pi is "Floor(1.5): 0". I have seen that System.Math.Floor is implemented as</p> <pre><code>[MethodImplAttribute (MethodImplOptions.InternalCall)] public extern static double Floor (double d); </code></pre> <p>Tomorrow, I will look further into this issue. Does anyone know why this issue could exist?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload