Пример #1
0
        private static void RunAssertionISO8601Date(
            RegressionEnvironment env,
            AtomicLong milestone)
        {
            var epl = "@Name('s0') select " +
                      "cast('1997-07-16T19:20:30Z',dtx,dateformat:'iso') as c0," +
                      "cast('1997-07-16T19:20:30+01:00',dtx,dateformat:'iso') as c1," +
                      "cast('1997-07-16T19:20:30',dtx,dateformat:'iso') as c2," +
                      "cast('1997-07-16T19:20:30.45Z',dtx,dateformat:'iso') as c3," +
                      "cast('1997-07-16T19:20:30.45+01:00',dtx,dateformat:'iso') as c4," +
                      "cast('1997-07-16T19:20:30.45',dtx,dateformat:'iso') as c5," +
                      "cast('1997-07-16T19:20:30.45',long,dateformat:'iso') as c6," +
                      "cast('1997-07-16T19:20:30.45',datetime,dateformat:'iso') as c7," +
                      "cast(TheString,dtx,dateformat:'iso') as c8," +
                      "cast(TheString,long,dateformat:'iso') as c9," +
                      "cast(TheString,datetime,dateformat:'iso') as c10," +
                      "cast('1997-07-16T19:20:30.45',datetimeoffset,dateformat:'iso') as c11," +
                      "cast('1997-07-16T19:20:30+01:00',datetime,dateformat:'iso') as c12," +
                      "cast('1997-07-16',datetimeoffset,dateformat:'iso') as c13," +
                      "cast('19:20:30',datetimeoffset,dateformat:'iso') as c14" +
                      " from SupportBean";

            env.CompileDeployAddListenerMile(epl, "s0", milestone.GetAndIncrement());

            env.SendEventBean(new SupportBean());
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c0"), 1997, 7, 16, 19, 20, 30, 0, "UTC");
            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c1"), 1997, 7, 16, 19, 20, 30, 0, "GMT+01:00");
            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c2"), 1997, 7, 16, 19, 20, 30, 0, "UTC");
            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c3"), 1997, 7, 16, 19, 20, 30, 450, "UTC");
            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c4"), 1997, 7, 16, 19, 20, 30, 450, "GMT+01:00");
            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c5"), 1997, 7, 16, 19, 20, 30, 450, "UTC");

            Assert.That(@event.Get("c6"), Is.InstanceOf <long>());
            Assert.That(@event.Get("c7"), Is.InstanceOf <DateTime>());

            foreach (var prop in "c8,c9,c10".SplitCsv())
            {
                Assert.IsNull(@event.Get(prop));
            }

            var isoDateTimeFormat = DateTimeFormat.ISO_DATE_TIME;

            var expectedC11 = isoDateTimeFormat.Parse("1997-07-16T19:20:30.45").DateTime;
            var expectedC12 = isoDateTimeFormat.Parse("1997-07-16T19:20:30+01:00").DateTime.DateTime;
            var expectedC13 = DateTimeParsingFunctions.ParseDefault("1997-07-16");
            var expectedC14 = DateTimeParsingFunctions.ParseDefault("19:20:30");

            Assert.That(@event.Get("c11"), Is.EqualTo(expectedC11));
            Assert.That(@event.Get("c12"), Is.EqualTo(expectedC12));
            Assert.That(@event.Get("c13"), Is.EqualTo(expectedC13));
            Assert.That(@event.Get("c14"), Is.EqualTo(expectedC14));

            env.UndeployAll();
        }
Пример #2
0
 public static DateTimeOffset ParseDateTimeOffset(string value)
 {
     value = value.TrimEnd();
     return(DateTimeParsingFunctions.ParseDefault(value));
 }