Mono, Dates, and Times

Just like the .NET Framework, Mono provides several classes for dealing with dates and times. In this section, we take a closer look at the fundamentals you should be familiar with.

DateTime

The DateTime object contains the basic mechanisms for managing dates and time.

Constructors

The following listing shows a simple example:

using System;

public class Demo
{
        public static void Main()
        {
                DateTime x = new DateTime(
                        1978,           // year
                        9,              // month
                        8,              // day
                        18,             // hour
                        35,             // minute
                        5,              // second
                        15);

                Console.WriteLine("{0:F}", x);
        }
}

We call the constructor of the DateTime object and pass a set of parameters to it. The meaning of the various parameters is described by the comments on the right edge of the code. To display the ...

Get Mono Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.