vendredi 21 juin 2019

How to run Rust tests with an explicit time zone (using chrono)

I am building some tests that do timestamp conversions in Rust using the chrono crate, and need to make sure they take into account the local time zone. However, the tests will be run in multiple time zones and so will fail for most testers. How can I force Rust or chrono within the code to use a specific time zone when running tests?

I know about setting env TZ=CST or similar. Since I cannot control that part of the execution environment for all those running cargo test, I don't think this works for us.

Aucun commentaire:

Enregistrer un commentaire