示例#1
0
        public void FixTo()
        {
            var ex = new TimeExpression("time < 1455376521s");

            ex.From.Should().Be(null);
            ex.To.Should().Be(new DateTime(2016, 2, 13, 16, 15, 21, DateTimeKind.Local).ToUniversalTime());
        }
示例#2
0
        public void FixFrom()
        {
            var ex = new TimeExpression("time > 1455354920s");

            ex.From.Should().Be(new DateTime(2016, 2, 13, 10, 15, 20, DateTimeKind.Local).ToUniversalTime());
            ex.To.Should().Be(null);
        }
示例#3
0
        public void RelativeTo()
        {
            var ex = new TimeExpression("time < now() - 6h");

            var shouldTime = DateTime.UtcNow - TimeSpan.FromHours(6);

            var diff = shouldTime - ex.To.Value;

            Math.Abs(diff.TotalMinutes).Should().BeLessThan(1);
        }