python;gutter:true;
use chrono::prelude::*;</p>
<p>// 1. 时间转字符
// 2. 字符转时间
// 3. 时间相加减
// 4. 时间加差异数</p>
<p>fn main(){
let d = NaiveDate::from_ymd(2015, 3, 14);
let a = NaiveDate::from_ymd(2015, 3, 16);
let a_b :i64 = (d-a).num_days();
// println!("{:?}", (d-a).num_days());
// let c = a + chrono::Duration::from(1);
// println!("{:?}", c);</p>
<pre><code>let x = NaiveDate::parse_from_str("2015/9/30", "%Y/%m/%d");
// println!("{:?}",x);
let y = x.unwrap() + chrono::Duration::days(-1_i64); //i64类型
print!(" => {:?}", y);
</code></pre>
<p>}
Original: https://www.cnblogs.com/pythonClub/p/16544329.html
Author: CrossPython
Title: rust chrono
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/15770/
转载文章受原作者版权保护。转载请注明原作者出处!