예제 #1
0
        public void Run()
        {
            var time_1 = new MyTime(14, 19, 4);

            Console.WriteLine("First date - " + time_1);

            Console.WriteLine("What lesson of first - " + time_1.WhatLesson());

            time_1.AddSeconds(125);
            Console.WriteLine("Adding 125 sec to first\n" + time_1);

            Console.WriteLine("What lesson of first - " + time_1.WhatLesson());

            var sec = MyTime.TimeSinceMidnight(time_1);

            Console.WriteLine(sec + " sec since midnight of first");

            Console.WriteLine("back from sec to first date: " + MyTime.TimeSinceMidnight(sec));

            var time_2 = new MyTime(15, 20, 7);

            Console.WriteLine("Second date - " + time_2);

            Console.WriteLine("What lesson of second - " + time_2.WhatLesson());

            var gap = MyTime.DifferenceBetween(time_1, time_2);

            Console.WriteLine("Difference between first & second: " + gap);
        }
예제 #2
0
 public static int TimeSinceMidnight(MyTime mt1) => mt1.second + mt1.minute * 60 + mt1.hour * 3600;
예제 #3
0
 public static MyTime DifferenceBetween(MyTime mt1, MyTime mt2) => mt1 - mt2;