# Candid failed to decode for internal error

**URL:** <https://forum.dfinity.org/t/candid-failed-to-decode-for-internal-error/20960>\
**Category:** Developers\
**Tags:** candid, Discussing\
**Created:** [June 25, 2023, 10:13am UTC](https://forum.dfinity.org/t/candid-failed-to-decode-for-internal-error/20960 "2023-06-25T10:13:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![famouscat8](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/famouscat8/32/4732_2.png) [@famouscat8](https://forum.dfinity.org/u/famouscat8)\
**Post date:** [June 25, 2023, 10:58am UTC](https://forum.dfinity.org/t/candid-failed-to-decode-for-internal-error/20960/2 "2023-06-25T10:58:56Z")

</div>

We need to implment our own `Deserializer` in this situation:

```rust
pub struct Suggection {
    pub id: i32,
    pub title: String,
    pub content: Option<String>,
    pub principal: String,
    #[serde(with = "timestamp_format")]
    pub created_at: time::OffsetDateTime,
}

mod timestamp_format {
    use candid::Deserialize;
    use serde::de::Error as SerdeError;
    use serde::{Deserializer, Serializer};
    use time::PrimitiveDateTime;
    use time::{Duration, OffsetDateTime};

    pub fn deserialize<'de, D>(deserializer: D) -> Result<OffsetDateTime, D::Error>
    where
        D: Deserializer<'de>,
    {
        let timestamp = u128::deserialize(deserializer)?;
        Ok(OffsetDateTime::from_unix_timestamp_nanos(timestamp.try_into().unwrap()).unwrap())
    }
}

```

---

_[View the full topic](https://forum.dfinity.org/t/candid-failed-to-decode-for-internal-error/20960)._
