diff options
Diffstat (limited to 'src/otp.rs')
-rw-r--r-- | src/otp.rs | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -256,14 +256,22 @@ pub trait GenerateOtp { /// /// # Example /// - /// ```no_run + /// ```ignore + /// extern crate chrono; + /// /// use nitrokey::GenerateOtp; /// # use nitrokey::CommandError; /// /// # fn try_main() -> Result<(), CommandError> { /// let device = nitrokey::connect()?; - /// let code = device.get_totp_code(1)?; - /// println!("Generated TOTP code on slot 1: {:?}", code); + /// let time = Utc::now().timestamp(); + /// if time < 0 { + /// println!("Timestamps before 1970-01-01 are not supported!"); + /// } else { + /// device.set_time(time as u64); + /// let code = device.get_totp_code(1)?; + /// println!("Generated TOTP code on slot 1: {:?}", code); + /// } /// # Ok(()) /// # } /// ``` |