summaryrefslogtreecommitdiff
path: root/nitrokey/src/otp.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-01-09 09:43:09 -0800
committerDaniel Mueller <deso@posteo.net>2019-01-09 09:43:09 -0800
commit333d17fb7b7a0eb43b7907fe7282c36ded2bd22e (patch)
tree15b4eef1e0001defc060a36f14e9f462a80d9980 /nitrokey/src/otp.rs
parentaa24eea9b5f70e9d2551f7753df4d12d14231603 (diff)
downloadnitrocli-333d17fb7b7a0eb43b7907fe7282c36ded2bd22e.tar.gz
nitrocli-333d17fb7b7a0eb43b7907fe7282c36ded2bd22e.tar.bz2
Update nitrokey crate to 0.3.1
This change updates the nitrokey crate to version 0.3.1. Import subrepo nitrokey/:nitrokey at bad12ad3c57c67d42243338af7d65c3591fed327
Diffstat (limited to 'nitrokey/src/otp.rs')
-rw-r--r--nitrokey/src/otp.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/nitrokey/src/otp.rs b/nitrokey/src/otp.rs
index 9f0a388..901bef9 100644
--- a/nitrokey/src/otp.rs
+++ b/nitrokey/src/otp.rs
@@ -155,7 +155,7 @@ pub trait GenerateOtp {
///
/// `time` is the number of seconds since January 1st, 1970 (Unix timestamp). Unless `force`
/// is set to `true`, this command fails if the timestamp on the device is larger than the
- /// given timestamp or if it is zero.
+ /// given timestamp or if it is zero.
///
/// The time is used for TOTP generation (see [`get_totp_code`][]).
///
@@ -297,21 +297,21 @@ pub trait GenerateOtp {
///
/// # Example
///
- /// ```ignore
- /// extern crate chrono;
- ///
+ /// ```no_run
+ /// use std::time;
/// use nitrokey::GenerateOtp;
/// # use nitrokey::CommandError;
///
/// # fn try_main() -> Result<(), CommandError> {
/// let device = nitrokey::connect()?;
- /// 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);
+ /// let time = time::SystemTime::now().duration_since(time::UNIX_EPOCH);
+ /// match time {
+ /// Ok(time) => {
+ /// device.set_time(time.as_secs(), false)?;
+ /// let code = device.get_totp_code(1)?;
+ /// println!("Generated TOTP code on slot 1: {}", code);
+ /// },
+ /// Err(_) => println!("Timestamps before 1970-01-01 are not supported!"),
/// }
/// # Ok(())
/// # }