parent
29ed19c5e0
commit
254381e3ca
|
@ -831,9 +831,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.22"
|
version = "0.4.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1"
|
checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iana-time-zone",
|
"iana-time-zone",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
|
|
@ -2412,7 +2412,11 @@ impl fmt::Display for CliBlock {
|
||||||
self.encoded_confirmed_block.previous_blockhash
|
self.encoded_confirmed_block.previous_blockhash
|
||||||
)?;
|
)?;
|
||||||
if let Some(block_time) = self.encoded_confirmed_block.block_time {
|
if let Some(block_time) = self.encoded_confirmed_block.block_time {
|
||||||
writeln!(f, "Block Time: {:?}", Local.timestamp(block_time, 0))?;
|
writeln!(
|
||||||
|
f,
|
||||||
|
"Block Time: {:?}",
|
||||||
|
Local.timestamp_opt(block_time, 0).unwrap()
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
if let Some(block_height) = self.encoded_confirmed_block.block_height {
|
if let Some(block_height) = self.encoded_confirmed_block.block_height {
|
||||||
writeln!(f, "Block Height: {block_height:?}")?;
|
writeln!(f, "Block Height: {block_height:?}")?;
|
||||||
|
|
|
@ -322,8 +322,8 @@ fn write_block_time<W: io::Write>(
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
if let Some(block_time) = block_time {
|
if let Some(block_time) = block_time {
|
||||||
let block_time_output = match timezone {
|
let block_time_output = match timezone {
|
||||||
CliTimezone::Local => format!("{:?}", Local.timestamp(block_time, 0)),
|
CliTimezone::Local => format!("{:?}", Local.timestamp_opt(block_time, 0).unwrap()),
|
||||||
CliTimezone::Utc => format!("{:?}", Utc.timestamp(block_time, 0)),
|
CliTimezone::Utc => format!("{:?}", Utc.timestamp_opt(block_time, 0).unwrap()),
|
||||||
};
|
};
|
||||||
writeln!(w, "{prefix}Block Time: {block_time_output}",)?;
|
writeln!(w, "{prefix}Block Time: {block_time_output}",)?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -596,7 +596,9 @@ fn release_channel_version_url(release_channel: &str) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_update_manifest(update_manifest: &UpdateManifest) {
|
fn print_update_manifest(update_manifest: &UpdateManifest) {
|
||||||
let when = Local.timestamp(update_manifest.timestamp_secs as i64, 0);
|
let when = Local
|
||||||
|
.timestamp_opt(update_manifest.timestamp_secs as i64, 0)
|
||||||
|
.unwrap();
|
||||||
println_name_value(&format!("{BULLET}release date:"), &when.to_string());
|
println_name_value(&format!("{BULLET}release date:"), &when.to_string());
|
||||||
println_name_value(
|
println_name_value(
|
||||||
&format!("{BULLET}download URL:"),
|
&format!("{BULLET}download URL:"),
|
||||||
|
|
|
@ -5,7 +5,7 @@ use bincode::{deserialize, serialized_size};
|
||||||
use {
|
use {
|
||||||
crate::{config_instruction, ConfigState},
|
crate::{config_instruction, ConfigState},
|
||||||
chrono::{
|
chrono::{
|
||||||
prelude::{Date, DateTime, TimeZone, Utc},
|
prelude::{DateTime, TimeZone, Utc},
|
||||||
serde::ts_seconds,
|
serde::ts_seconds,
|
||||||
},
|
},
|
||||||
serde_derive::{Deserialize, Serialize},
|
serde_derive::{Deserialize, Serialize},
|
||||||
|
@ -21,15 +21,13 @@ pub struct DateConfig {
|
||||||
impl Default for DateConfig {
|
impl Default for DateConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
date_time: Utc.timestamp(0, 0),
|
date_time: Utc.timestamp_opt(0, 0).unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl DateConfig {
|
impl DateConfig {
|
||||||
pub fn new(date: Date<Utc>) -> Self {
|
pub fn new(date_time: DateTime<Utc>) -> Self {
|
||||||
Self {
|
Self { date_time }
|
||||||
date_time: date.and_hms(0, 0, 0),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deserialize(input: &[u8]) -> Option<Self> {
|
pub fn deserialize(input: &[u8]) -> Option<Self> {
|
||||||
|
@ -54,7 +52,7 @@ pub fn create_account(
|
||||||
|
|
||||||
/// Set the date in the date account. The account pubkey must be signed in the
|
/// Set the date in the date account. The account pubkey must be signed in the
|
||||||
/// transaction containing this instruction.
|
/// transaction containing this instruction.
|
||||||
pub fn store(date_pubkey: &Pubkey, date: Date<Utc>) -> Instruction {
|
pub fn store(date_pubkey: &Pubkey, date_time: DateTime<Utc>) -> Instruction {
|
||||||
let date_config = DateConfig::new(date);
|
let date_config = DateConfig::new(date_time);
|
||||||
config_instruction::store(date_pubkey, true, vec![], &date_config)
|
config_instruction::store(date_pubkey, true, vec![], &date_config)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ homepage = "https://solana.com/"
|
||||||
documentation = "https://docs.rs/solana-tokens"
|
documentation = "https://docs.rs/solana-tokens"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4.23", features = ["serde"] }
|
||||||
clap = "2.33.0"
|
clap = "2.33.0"
|
||||||
console = "0.15.0"
|
console = "0.15.0"
|
||||||
csv = "1.1.6"
|
csv = "1.1.6"
|
||||||
|
|
|
@ -218,11 +218,11 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sort_transaction_infos_finalized_first() {
|
fn test_sort_transaction_infos_finalized_first() {
|
||||||
let info0 = TransactionInfo {
|
let info0 = TransactionInfo {
|
||||||
finalized_date: Some(Utc.ymd(2014, 7, 8).and_hms(9, 10, 11)),
|
finalized_date: Some(Utc.with_ymd_and_hms(2014, 7, 8, 9, 10, 11).unwrap()),
|
||||||
..TransactionInfo::default()
|
..TransactionInfo::default()
|
||||||
};
|
};
|
||||||
let info1 = TransactionInfo {
|
let info1 = TransactionInfo {
|
||||||
finalized_date: Some(Utc.ymd(2014, 7, 8).and_hms(9, 10, 42)),
|
finalized_date: Some(Utc.with_ymd_and_hms(2014, 7, 8, 9, 10, 42).unwrap()),
|
||||||
..TransactionInfo::default()
|
..TransactionInfo::default()
|
||||||
};
|
};
|
||||||
let info2 = TransactionInfo::default();
|
let info2 = TransactionInfo::default();
|
||||||
|
|
Loading…
Reference in New Issue