don't truncate DateTime nanoseconds

where we don't care about them anyway..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2020-09-11 14:34:35 +02:00 committed by Dietmar Maurer
parent 4a363fb4a7
commit 151acf5d96
5 changed files with 11 additions and 11 deletions

View File

@ -10,7 +10,7 @@
use std::io::Write;
use anyhow::{bail, Error};
use chrono::{Local, TimeZone, DateTime};
use chrono::{Local, DateTime};
use openssl::hash::MessageDigest;
use openssl::pkcs5::pbkdf2_hmac;
use openssl::symm::{decrypt_aead, Cipher, Crypter, Mode};
@ -219,7 +219,7 @@ impl CryptConfig {
created: DateTime<Local>,
) -> Result<Vec<u8>, Error> {
let modified = Local.timestamp(Local::now().timestamp(), 0);
let modified = Local::now();
let key_config = super::KeyConfig { kdf: None, created, modified, data: self.enc_key.to_vec() };
let data = serde_json::to_string(&key_config)?.as_bytes().to_vec();

View File

@ -1,7 +1,7 @@
use anyhow::{bail, format_err, Context, Error};
use serde::{Deserialize, Serialize};
use chrono::{Local, TimeZone, DateTime};
use chrono::{Local, DateTime};
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
use proxmox::try_block;
@ -136,7 +136,7 @@ pub fn encrypt_key_with_passphrase(
enc_data.extend_from_slice(&tag);
enc_data.extend_from_slice(&encrypted_key);
let created = Local.timestamp(Local::now().timestamp(), 0);
let created = Local::now();
Ok(KeyConfig {
kdf: Some(kdf),

View File

@ -3,7 +3,7 @@ use std::sync::Arc;
use anyhow::{Error};
use serde_json::Value;
use chrono::{TimeZone, Utc};
use chrono::Utc;
use serde::Serialize;
use proxmox::api::{ApiMethod, RpcEnvironment};
@ -212,7 +212,7 @@ async fn test_upload_speed(
verbose: bool,
) -> Result<(), Error> {
let backup_time = Utc.timestamp(Utc::now().timestamp(), 0);
let backup_time = Utc::now();
let client = connect(repo.host(), repo.user())?;
record_repository(&repo);

View File

@ -1,7 +1,7 @@
use std::path::PathBuf;
use anyhow::{bail, format_err, Error};
use chrono::{Local, TimeZone};
use chrono::Local;
use serde::{Deserialize, Serialize};
use proxmox::api::api;
@ -112,7 +112,7 @@ fn create(kdf: Option<Kdf>, path: Option<String>) -> Result<(), Error> {
match kdf {
Kdf::None => {
let created = Local.timestamp(Local::now().timestamp(), 0);
let created = Local::now();
store_key_config(
&path,
@ -180,7 +180,7 @@ fn change_passphrase(kdf: Option<Kdf>, path: Option<String>) -> Result<(), Error
match kdf {
Kdf::None => {
let modified = Local.timestamp(Local::now().timestamp(), 0);
let modified = Local::now();
store_key_config(
&path,

View File

@ -1,5 +1,5 @@
use anyhow::{Error};
use chrono::{TimeZone, Local};
use chrono::Local;
use std::io::Write;
/// Log messages with timestamps into files
@ -56,7 +56,7 @@ impl FileLogger {
stdout.write_all(b"\n").unwrap();
}
let line = format!("{}: {}\n", Local.timestamp(Local::now().timestamp(), 0).to_rfc3339(), msg);
let line = format!("{}: {}\n", Local::now().to_rfc3339(), msg);
self.file.write_all(line.as_bytes()).unwrap();
}
}