Ejemplo n.º 1
0
        private static void userDatesAndTimes()
        {
            System.Console.WriteLine("=> Dates and Times:");

            // datetime constructor
            DateTime dt = new DateTime(2021, 10, 17);

            // day?
            System.Console.WriteLine($"the day of {dt.Date} is {dt.DayOfWeek}");

            // month?
            dt = dt.AddMonth(2);
            System.Console.WriteLine($"Daylight savings: {dt.isDayLightSavingTime()}");

            // time constructor
            TimeSpan ts = new TimeSpan(4, 30, 0);

            System.Console.WriteLine(ts);

            // time difference: t1 - t2
            System.Console.WriteLine(ts.Subtract(new TimeSpan(0, 15, 0)));
        }