Time Arithmetic by Geroge2k

\xef\xbb\xbfusing System;\x0d
using System.IO;\x0d
\x0d
namespace CodeGolf\x0d
{\x0d
    class timeArithmetic\x0d
    {\x0d
        static void Main()\x0d
        {\x0d
            StreamReader reader = new StreamReader(Console.OpenStandardInput());\x0d
            string[] lines = reader.ReadToEnd().Split(new[] {Environment.NewLine}, StringSplitOptions.None);\x0d
            foreach (var line in lines)\x0d
            {\x0d
                string[] times = line.Split('+');\x0d
                DateTime t1 = DateTime.Parse(times[0]);\x0d
                TimeSpan t2 = TimeSpan.Parse(times[1]);\x0d
                DateTime t3 = t1.Add(t2);\x0d
                Console.WriteLine("{0:HH\\:mm\\:ss}+{1:hh\\:mm\\:ss}={2:HH\\:mm\\:ss}", t1, t2, t3);\x0d
            }\x0d
        }\x0d
    }\x0d
}\x0d

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page