public void TestDate4FutureTolerance() { DateTime today = DateTime.UtcNow; DateTime soon = today.AddMilliseconds(50000); today = today.AddHours(0) .AddMinutes(0) .AddSeconds(0) .AddMilliseconds(0); var buf = IsoType.DATE4.Format(soon).GetSbytes(); var comp = new Date4ParseInfo().Parse(0, buf, 0, null); Assert.Equal(comp.Value, today.Date); MemoryStream stream = new MemoryStream(); comp.Write(stream, true, false); IsoValue bin = new Date4ParseInfo().ParseBinary(0, stream.ToArray().ToSbytes(), 0, null); DateTime dt = (DateTime)(comp.Value); DateTime bindt = (DateTime)bin.Value; Assert.Equal(dt.ToBinary(), bindt.ToBinary()); }
public void TestDate4() { var parser = new Date4ParseInfo { Encoding = CodePagesEncodingProvider.Instance.GetEncoding(1047), ForceStringDecoding = true }; var v = parser.Parse(1, new[] { (byte)240, (byte)241, (byte)242, (byte)245 }.ToSignedBytes(), 0, null); var val = (DateTime)v.Value; Assert.Equal("01", val.ToString("MM")); Assert.Equal("25", val.ToString("dd")); }