static void Main(string[] args) { DateTimeOffset time = DateTimeOffset.MinValue; while (time == DateTimeOffset.MinValue) { try { Console.WriteLine("Enter a time to see in Berlin Clock Format. Input format: HH:MM:SS"); time = DateTimeOffset.Parse(Console.ReadLine()); } catch { Console.WriteLine("Error parsing the input string. Format should be HH:MM:SS"); } } var berlinTime = new BerlinClockTime(time); Console.WriteLine(berlinTime.ToString("F", new BerlinClockTimeFormatter())); Console.ReadKey(); }
StringBuilder AppendQuarters(StringBuilder sb, BerlinClockTime clock) { sb.AppendLine(Enumerable.Repeat("YYR", clock.Quarters).Concat(Enumerable.Repeat("Y", clock.FiveMinutes)).TryAggregate().PadRight(11, 'O')); return(sb); }
StringBuilder AppendHours(StringBuilder sb, BerlinClockTime clock) { sb.AppendLine(Enumerable.Repeat("R", clock.NumberOfFiveHourSignals).TryAggregate().PadRight(4, 'O')); sb.AppendLine(Enumerable.Repeat("R", clock.NumberOfOneHourSignals).TryAggregate().PadRight(4, 'O')); return(sb); }
StringBuilder AppendSeconds(StringBuilder sb, BerlinClockTime clock) { sb.AppendLine(clock.IsTwoSecondClockBlinking ? "Y" : "O"); return(sb); }
StringBuilder AppendSingleMinutes(StringBuilder sb, BerlinClockTime clock) { sb.AppendLine(Enumerable.Repeat("Y", clock.SingleMinutes).TryAggregate().PadRight(4, 'O')); return(sb); }