Sha256: 0a415f9213523b32c362804c6568876fbb3b4df6c22225f0702de2a4d048ce69
Contents?: true
Size: 1.23 KB
Versions: 86
Compression:
Stored size: 1.23 KB
Contents
using System; using System.Collections.Generic; using Generators.Input; using Generators.Output; namespace Generators.Exercises { public class Gigasecond : GeneratorExercise { protected override void UpdateCanonicalData(CanonicalData canonicalData) { foreach (var canonicalDataCase in canonicalData.Cases) { var input = DateTime.Parse(canonicalDataCase.Properties["input"].ToString()); canonicalDataCase.Properties["input"] = new UnescapedValue(FormatDateTime(input)); canonicalDataCase.Expected = new UnescapedValue(FormatDateTime((DateTime)canonicalDataCase.Expected)); } } protected override HashSet<string> AddAdditionalNamespaces() => new HashSet<string> { typeof(DateTime).Namespace }; private static string FormatDateTime(DateTime dateTime) { return dateTime.Hour == 0 && dateTime.Minute == 0 && dateTime.Second == 0 ? $"new DateTime({dateTime.Year}, {dateTime.Month}, {dateTime.Day})" : $"new DateTime({dateTime.Year}, {dateTime.Month}, {dateTime.Day}, {dateTime.Hour}, {dateTime.Minute}, {dateTime.Second})"; } } }
Version data entries
86 entries across 86 versions & 1 rubygems