public void TruncateToSecond() { var time = LocalTime.FromMillisecondsSinceMidnight(3042); var truncated = Snippet.For(TimeAdjusters.TruncateToSecond(time)); Assert.AreEqual(LocalTime.FromSecondsSinceMidnight(3), truncated); }
public virtual void TestSchemaEncodeDecodeFidelity() { var schema = LocalTimeSchema.Of(); var localTime = LocalTime.FromMillisecondsSinceMidnight((int)(DateTime.Now - DateTime.Today).TotalMilliseconds); var bytes = schema.Encode(localTime); Assert.Equal(localTime, schema.Decode(bytes)); }
public static ZoneYearOffset Read([NotNull] IDateTimeZoneReader reader) { Preconditions.CheckNotNull(reader, nameof(reader)); int flags = reader.ReadByte(); var mode = (TransitionMode)(flags >> 5); var dayOfWeek = (flags >> 2) & 7; var advance = (flags & 2) != 0; var addDay = (flags & 1) != 0; int monthOfYear = reader.ReadCount(); int dayOfMonth = reader.ReadSignedCount(); // The time of day is written as a number of milliseconds for historical reasons. var timeOfDay = LocalTime.FromMillisecondsSinceMidnight(reader.ReadMilliseconds()); return(new ZoneYearOffset(mode, monthOfYear, dayOfMonth, dayOfWeek, advance, timeOfDay, addDay)); }
public void FromMillisecondsSinceMidnight_RangeChecks() { Assert.Throws <ArgumentOutOfRangeException>(() => LocalTime.FromMillisecondsSinceMidnight(-1)); Assert.Throws <ArgumentOutOfRangeException>(() => LocalTime.FromMillisecondsSinceMidnight(NodaConstants.MillisecondsPerDay)); }
public void FromMillisecondsSinceMidnight_Valid() { Assert.AreEqual(LocalTime.Midnight, LocalTime.FromMillisecondsSinceMidnight(0)); Assert.AreEqual(LocalTime.Midnight - Period.FromMilliseconds(1), LocalTime.FromMillisecondsSinceMidnight(NodaConstants.MillisecondsPerDay - 1)); }