[Git][reproducible-builds/reproducible-website][master] Add simplified Rust SDE example

Bernhard M. Wiedemann (@bmwiedemann-guest) gitlab at salsa.debian.org
Wed Jun 28 14:37:05 UTC 2023



Bernhard M. Wiedemann pushed to branch master at Reproducible Builds / reproducible-website


Commits:
f4b89e17 by Bernhard M. Wiedemann at 2023-06-28T16:36:37+02:00
Add simplified Rust SDE example

tested with rust 1.70 and chrono 0.4.26

- - - - -


1 changed file:

- _docs/source-date-epoch.md


Changes:

=====================================
_docs/source-date-epoch.md
=====================================
@@ -384,6 +384,16 @@ sys.env.get("SOURCE_DATE_EPOCH")
 
 Using the `chrono` crate:
 
+```rust
+use chrono::{TimeZone, Utc};
+use std::env;
+
+let now = match env::var("SOURCE_DATE_EPOCH") {
+    Ok(val) => { Utc.timestamp_opt(val.parse::<i64>().unwrap(), 0).unwrap() }
+    Err(_) => Utc::now(),
+};
+```
+or
 ```rust
 use chrono::{DateTime, NaiveDateTime, Utc};
 use std::env;



View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/-/commit/f4b89e177f05511ebb790fe0d1c571709c361c59

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/-/commit/f4b89e177f05511ebb790fe0d1c571709c361c59
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20230628/4043bd5e/attachment.htm>


More information about the rb-commits mailing list