using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DateTimeTest
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime dt1 = new DateTime(2008, 10, 2, 23, 3, 59, 10, DateTimeKind.Utc);
            DateTime dt2 = new DateTime(2008, 10, 2, new System.Globalization.JapaneseCalendar());
            Console.WriteLine("date : {0}", dt1);
            Console.WriteLine("date : {0}", dt2);
            Console.WriteLine(dt2.Kind);
            DateTime dt3 = new DateTime(2008, 10, 2);
            DateTime dt4 = new DateTime(2008, 10, 4);
            TimeSpan ts = TimeSpan.FromDays(2);
            Console.WriteLine(dt3 == dt4);
            Console.WriteLine(dt3 > dt4);
            Console.WriteLine(DateTime.Compare(dt3, dt4));
            dt3 = dt3.Add(ts);
            Console.WriteLine(DateTime.Compare(dt3, dt4));
            dt3 = dt3 + ts;
            Console.WriteLine(DateTime.Compare(dt3, dt4));
            DateTime dt5 = new DateTime(2008, 10, 2, 23, 3, 59, 10);
            Console.WriteLine("affichage format court {0:d}", dt5);
            string str_convert = string.Format("la meme au format long {0:D}", dt5);
            Console.WriteLine(str_convert);
            Console.WriteLine(dt5.ToString("dddd, le d MMMM yyyy"));
            Console.WriteLine(dt5.ToString("ce dd/MMM à HH:mm"));
            Console.WriteLine(dt5.ToString("à HH heures mm minutes"));
            Console.WriteLine(dt5.ToString("à HH 'heures' mm 'minutes'"));
            string str = "2/11/09";
            DateTime dt7;
            if (DateTime.TryParse(str, out dt7) == false)
                Console.WriteLine("echec du PArse nouvelle saisie");
            else
                Console.WriteLine("date convertie ds la culture {0} {1:d}", System.Globalization.CultureInfo.CurrentUICulture, dt7);
            DateTime dt8;
            dt8 = DateTime.Parse(str, System.Globalization.CultureInfo.InvariantCulture);// System.Globalization.DateTimeStyles.None);
            Console.WriteLine("dans InvariantCulture mois et jour sont inversé {0:d}", dt8);
            DateTime dt9 = new DateTime(2009, 5, 3, 13, 10, 53);// J=5/M=3/A=2009 13h10mn53s
            Console.WriteLine("culture dependant {0:d}", dt9);
            Console.WriteLine("insensible culture {0:o}", dt9);


            Console.ReadKey();
        }
    }
}
