private object ConvertReverseTicksToLocalDateTimeString(TemperatureEntity temperature, TemperatureViewModel destination, string destMember, ResolutionContext context)
        {
            if (string.IsNullOrWhiteSpace(temperature.RowKey))
            {
                return(null);
            }

            context.Items.TryGetValue("DateTimeZone", out var ianaTimeZone);

            var dateTimeZone = ianaTimeZone as DateTimeZone;

            if (dateTimeZone == null)
            {
                return(null);
            }

            return(ReverseTicks.ToZonedDateTime(temperature.RowKey, dateTimeZone).ToOffsetDateTime().ToString());
        }
        private object GetLocalDateFromContextOrRowKey(TemperatureSummaryEntity source, TemperatureSummaryViewModel destination, string destMember, ResolutionContext context)
        {
            context.Items.TryGetValue("LocalDate", out var localDate);

            if (localDate is LocalDate)
            {
                return(((LocalDate)localDate).ToString("yyyy-MM-dd", null));
            }

            context.Items.TryGetValue("DateTimeZone", out var dateTimeZone);

            if (dateTimeZone is DateTimeZone && !string.IsNullOrWhiteSpace(source.RowKey))
            {
                return(ReverseTicks.ToZonedDateTime(source.RowKey, (DateTimeZone)dateTimeZone).ToString("yyyy-MM-dd", null));
            }

            return(null);
        }
Exemplo n.º 3
0
        public void ReverseTick_Convert_Test()
        {
            var expected = new DateTime(2017, 1, 15, 15, 5, 23, DateTimeKind.Utc);

            Assert.AreEqual(expected, ReverseTicks.ToDateTime(expected.ToReverseTicks()));
        }