Skip to content

Commit 45e742f

Browse files
committed
committing progress
1 parent 7dc3598 commit 45e742f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

primitives/src/ad_slot.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::{BigNum, TargetingTag, ValidatorId, targeting::Rule};
2-
use chrono::serde::{ts_milliseconds, ts_milliseconds_option};
32
use chrono::{DateTime, Utc};
43
use serde::{Deserialize, Serialize};
54
use std::collections::HashMap;
@@ -22,16 +21,6 @@ pub struct AdSlot {
2221
/// see IAB ad unit guidelines and iab_flex_{adUnitName} (see IAB's new ad portfolio and PDF)
2322
#[serde(rename = "type")]
2423
pub ad_type: String,
25-
/// A URL to the resource (usually PNG)
26-
/// * must use the ipfs:// protocol, to guarantee data immutability
27-
pub media_url: String,
28-
/// MIME type of the media.
29-
// Possible values at the moment are:
30-
/// * image/jpeg
31-
/// * image/png
32-
pub media_mime: String,
33-
/// Advertised URL
34-
pub target_url: String,
3524
/// Array of TargetingTag
3625
#[serde(default)]
3726
pub targeting: Vec<TargetingTag>,
@@ -53,7 +42,7 @@ pub struct AdSlot {
5342
/// User address from the session
5443
pub owner: ValidatorId,
5544
/// UTC timestamp in milliseconds, used as nonce for escaping duplicated spec ipfs hashes
56-
#[serde(with = "ts_milliseconds")]
45+
#[serde(deserialize_with = "from_timestamp")]
5746
pub created: DateTime<Utc>,
5847
/// the name of the unit used in platform UI
5948
#[serde(default)]
@@ -67,6 +56,17 @@ pub struct AdSlot {
6756
#[serde(default)]
6857
pub archived: bool,
6958
/// UTC timestamp in milliseconds, changed every time modifiable property is changed
70-
#[serde(default, with = "ts_milliseconds_option")]
59+
#[serde(deserialize_with = "from_timestamp_option")]
7160
pub modified: Option<DateTime<Utc>>,
7261
}
62+
63+
fn from_timestamp(time: &String) -> DateTime<Utc> {
64+
DateTime::parse_from_str(time, "%Y-%m-%dT%H:%M:%S.%f").unwrap()
65+
}
66+
67+
fn from_timestamp_option(time: &String) -> Option<DateTime<Utc>> {
68+
match DateTime::parse_from_str(time, "%Y-%m-%dT%H:%M:%S.%f") {
69+
Ok(t) => Some(t),
70+
Err(_) => None,
71+
}
72+
}

0 commit comments

Comments
 (0)