Ejemplo n.º 1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
        {
            if (reader.TokenType == JsonToken.Null)
            {
                return(null);
            }

            var value = reader.Value.ToString();
            var date  = TwitterDateTime.ConvertToDateTime(value);

            return(date);
        }
Ejemplo n.º 2
0
        public override void WriteJson(JsonWriter writer, object?value, Newtonsoft.Json.JsonSerializer serializer)
        {
            if (value is TwitterDateTime)
            {
                writer.WriteValue(value.ToString());
            }

            if (value is DateTime dateTime)
            {
                var converted = TwitterDateTime.ConvertFromDateTime(dateTime, TwitterDateFormat.RestApi);

                writer.WriteValue(converted);
            }
        }