Skip to content

Commit

Permalink
Use DateTime instead of NaiveDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpringle committed Apr 2, 2024
1 parent c6ce2ba commit fb2ead4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
jsonrpc::client::p as client_p,
key, platformvm, txs, units,
};
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
use chrono::{DateTime, TimeZone, Utc};
use tokio::time::{sleep, Duration, Instant};

/// Represents P-chain "AddPermissionlessValidator" transaction.
Expand Down Expand Up @@ -64,14 +64,14 @@ where
.as_secs();

let start_time = now_unix + 60;
let naive_dt = NaiveDateTime::from_timestamp_opt(start_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(start_time as i64, 0).unwrap();
let start_time = Utc.from_utc_datetime(&naive_dt);

// 100-day
// must be smaller than the primary network default
// otherwise "staking period must be a subset of the primary network"
let end_time = now_unix + 100 * 24 * 60 * 60;
let naive_dt = NaiveDateTime::from_timestamp_opt(end_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(end_time as i64, 0).unwrap();
let end_time = Utc.from_utc_datetime(&naive_dt);

Self {
Expand Down Expand Up @@ -135,13 +135,13 @@ where
.as_secs();

let start_time = now_unix + offset_seconds;
let naive_dt = NaiveDateTime::from_timestamp_opt(start_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(start_time as i64, 0).unwrap();
let start_time = Utc.from_utc_datetime(&naive_dt);

// must be smaller than the primary network default
// otherwise "staking period must be a subset of the primary network"
let end_time = now_unix + days * 24 * 60 * 60;
let naive_dt = NaiveDateTime::from_timestamp_opt(end_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(end_time as i64, 0).unwrap();
let end_time = Utc.from_utc_datetime(&naive_dt);

self.start_time = start_time;
Expand Down
10 changes: 5 additions & 5 deletions crates/avalanche-types/src/wallet/p/add_subnet_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
jsonrpc::client::p as client_p,
key, platformvm, txs,
};
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
use chrono::{DateTime, TimeZone, Utc};
use tokio::time::{sleep, Duration, Instant};

/// Represents P-chain "AddSubnetValidator" transaction.
Expand Down Expand Up @@ -52,15 +52,15 @@ where
.as_secs();

let start_time = now_unix + 60;
let naive_dt = NaiveDateTime::from_timestamp_opt(start_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(start_time as i64, 0).unwrap();
let start_time = Utc.from_utc_datetime(&naive_dt);

// 14-day + 5-min
// must be smaller than the primary network default
// otherwise "staking period must be a subset of the primary network"
// ref. "Validator.BoundedBy"
let end_time = now_unix + 15 * 24 * 60 * 60 + 5 * 60;
let naive_dt = NaiveDateTime::from_timestamp_opt(end_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(end_time as i64, 0).unwrap();
let end_time = Utc.from_utc_datetime(&naive_dt);

Self {
Expand Down Expand Up @@ -122,13 +122,13 @@ where
.as_secs();

let start_time = now_unix + offset_seconds;
let naive_dt = NaiveDateTime::from_timestamp_opt(start_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(start_time as i64, 0).unwrap();
let start_time = Utc.from_utc_datetime(&naive_dt);

// must be smaller than the primary network default
// otherwise "staking period must be a subset of the primary network"
let end_time = now_unix + days * 24 * 60 * 60;
let naive_dt = NaiveDateTime::from_timestamp_opt(end_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(end_time as i64, 0).unwrap();
let end_time = Utc.from_utc_datetime(&naive_dt);

self.start_time = start_time;
Expand Down
10 changes: 5 additions & 5 deletions crates/avalanche-types/src/wallet/p/add_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
jsonrpc::client::p as client_p,
key, platformvm, txs, units,
};
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
use chrono::{DateTime, TimeZone, Utc};
use tokio::time::{sleep, Duration, Instant};

/// Represents P-chain "AddValidator" transaction.
Expand Down Expand Up @@ -60,7 +60,7 @@ where
.as_secs();

let start_time = now_unix + 60;
let naive_dt = NaiveDateTime::from_timestamp_opt(start_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(start_time as i64, 0).unwrap();
let start_time = Utc.from_utc_datetime(&naive_dt);

// 15-day + 5-min
Expand All @@ -69,7 +69,7 @@ where
// 15 that subnet validator defaults can be bounded within
// ref. "Validator.BoundedBy"
let end_time = now_unix + 14 * 24 * 60 * 60 + 5 * 60;
let naive_dt = NaiveDateTime::from_timestamp_opt(end_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(end_time as i64, 0).unwrap();
let end_time = Utc.from_utc_datetime(&naive_dt);

Self {
Expand Down Expand Up @@ -124,13 +124,13 @@ where
.as_secs();

let start_time = now_unix + offset_seconds;
let naive_dt = NaiveDateTime::from_timestamp_opt(start_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(start_time as i64, 0).unwrap();
let start_time = Utc.from_utc_datetime(&naive_dt);

// must be smaller than the primary network default
// otherwise "staking period must be a subset of the primary network"
let end_time = now_unix + days * 24 * 60 * 60;
let naive_dt = NaiveDateTime::from_timestamp_opt(end_time as i64, 0).unwrap();
let naive_dt = DateTime::from_timestamp(end_time as i64, 0).unwrap();
let end_time = Utc.from_utc_datetime(&naive_dt);

self.start_time = start_time;
Expand Down

0 comments on commit fb2ead4

Please sign in to comment.