Exemplo n.º 1
0
        public Result <string?>?TryToStringValue(object?value, Type type)
        {
            if (value == null)
            {
                return(null);
            }

            DateTime dateTime = (DateTime)value;

            SmartDateTimeSpan ss = SmartDateTimeSpan.Substract(dateTime, TimeZoneManager.Now);

            return(new Result <string?> .Success(ss.ToString()));
        }
Exemplo n.º 2
0
        public string TryToStringValue(object value, Type type, out string result)
        {
            if (value == null)
            {
                result = null;
                return(FilterValueConverter.Continue);
            }

            DateTime dateTime = (DateTime)value;

            SmartDateTimeSpan ss = SmartDateTimeSpan.Substract(dateTime, TimeZoneManager.Now);

            result = ss.ToString();
            return(null);
        }
    public Result <string?>?TryToStringValue(object?value, Type type)
    {
        if (value == null)
        {
            return(null);
        }

        DateTime dateTime =
            value is string s?DateTime.ParseExact(s, type == typeof(DateTime)? "o" : "yyyy-MM-dd", CultureInfo.InvariantCulture) :
                value is DateOnly d?d.ToDateTime() :
                    value is DateTime dt ? dt : throw new UnexpectedValueException(value);

        SmartDateTimeSpan ss = SmartDateTimeSpan.Substract(dateTime, Clock.Now);

        return(new Result <string?> .Success(ss.ToString()));
    }