Skip to main content

chrono_opt_to_timestamp

Function chrono_opt_to_timestamp 

Source
pub fn chrono_opt_to_timestamp(dt: Option<DateTime<Utc>>) -> Option<Timestamp>
Expand description

Convert an Option<DateTime<Utc>> to an optional proto Timestamp.

Returns None when the input is None, forwarding to chrono_to_timestamp otherwise.

ยงExample

use api_bones::connect::chrono_opt_to_timestamp;

assert!(chrono_opt_to_timestamp(None).is_none());
assert!(chrono_opt_to_timestamp(Some(chrono::Utc::now())).is_some());