Exemple #1
0
        public void ChangeTimeZone(string initialDateTime, string timeZone, string expected)
        {
            var input = new DateTimeValue(DateTimeOffset.Parse(initialDateTime));

            var arguments = new FilterArguments(new StringValue(timeZone));
            var context   = new TemplateContext {
                CultureInfo = CultureInfo.InvariantCulture
            };

            var result = MiscFilters.ChangeTimeZone(input, arguments, context);

            Assert.Equal(expected, ((DateTimeOffset)result.ToObjectValue()).ToString("yyyy-MM-ddTHH:mm:ssK"));
        }
Exemple #2
0
        public void ChangeTimeZoneAndApply12hFormat(string initialDateTime, string timeZone, string format, string expected)
        {
            var input            = new DateTimeValue(DateTimeOffset.Parse(initialDateTime));
            var timeZoneArgument = new FilterArguments(new StringValue(timeZone));
            var formatArgument   = new FilterArguments(new StringValue(format));
            var context          = new TemplateContext {
                CultureInfo = CultureInfo.InvariantCulture
            };

            var result = MiscFilters.ChangeTimeZone(input, timeZoneArgument, context);

            result = MiscFilters.Date(result, formatArgument, context);

            Assert.Equal(expected, result.ToStringValue().Trim());
        }