Rustでタイムスタンプがほしい時は多々ある。
time crateじゃもうdepricatedなので
chrono crateを使う。
$ cargo tree | grep chrono ├── chrono v0.4.1
extern crate chrono; use chrono::prelude::*; #[test] fn timestamp(){ let dt = Utc::now(); println!("{:?}", dt.timestamp()); }
たったこれだけだった
https://crates.io/crates/chrono
$date +%s
で得られるものと近い値が出ると思われる。
[試して理解]Linuxのしくみ ~実験と図解で学ぶOSとハードウェアの基礎知識
- 作者: 武内覚
- 出版社/メーカー: 技術評論社
- 発売日: 2018/02/23
- メディア: 単行本(ソフトカバー)
- この商品を含むブログ (1件) を見る