Bump chrono to v0.4.23 (#29709)

* Bump chrono to v0.4.23

* fmt...
This commit is contained in:
Ryo Onodera 2023-01-18 13:54:02 +09:00 committed by GitHub
parent 29ed19c5e0
commit 254381e3ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 17 deletions

4
Cargo.lock generated
View File

@ -831,9 +831,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.22"
version = "0.4.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1"
checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f"
dependencies = [
"iana-time-zone",
"js-sys",

View File

@ -2412,7 +2412,11 @@ impl fmt::Display for CliBlock {
self.encoded_confirmed_block.previous_blockhash
)?;
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 {
writeln!(f, "Block Height: {block_height:?}")?;

View File

@ -322,8 +322,8 @@ fn write_block_time<W: io::Write>(
) -> io::Result<()> {
if let Some(block_time) = block_time {
let block_time_output = match timezone {
CliTimezone::Local => format!("{:?}", Local.timestamp(block_time, 0)),
CliTimezone::Utc => format!("{:?}", Utc.timestamp(block_time, 0)),
CliTimezone::Local => format!("{:?}", Local.timestamp_opt(block_time, 0).unwrap()),
CliTimezone::Utc => format!("{:?}", Utc.timestamp_opt(block_time, 0).unwrap()),
};
writeln!(w, "{prefix}Block Time: {block_time_output}",)?;
}

View File

@ -596,7 +596,9 @@ fn release_channel_version_url(release_channel: &str) -> String {
}
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}download URL:"),

View File

@ -5,7 +5,7 @@ use bincode::{deserialize, serialized_size};
use {
crate::{config_instruction, ConfigState},
chrono::{
prelude::{Date, DateTime, TimeZone, Utc},
prelude::{DateTime, TimeZone, Utc},
serde::ts_seconds,
},
serde_derive::{Deserialize, Serialize},
@ -21,15 +21,13 @@ pub struct DateConfig {
impl Default for DateConfig {
fn default() -> Self {
Self {
date_time: Utc.timestamp(0, 0),
date_time: Utc.timestamp_opt(0, 0).unwrap(),
}
}
}
impl DateConfig {
pub fn new(date: Date<Utc>) -> Self {
Self {
date_time: date.and_hms(0, 0, 0),
}
pub fn new(date_time: DateTime<Utc>) -> Self {
Self { date_time }
}
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
/// transaction containing this instruction.
pub fn store(date_pubkey: &Pubkey, date: Date<Utc>) -> Instruction {
let date_config = DateConfig::new(date);
pub fn store(date_pubkey: &Pubkey, date_time: DateTime<Utc>) -> Instruction {
let date_config = DateConfig::new(date_time);
config_instruction::store(date_pubkey, true, vec![], &date_config)
}

View File

@ -10,7 +10,7 @@ homepage = "https://solana.com/"
documentation = "https://docs.rs/solana-tokens"
[dependencies]
chrono = { version = "0.4", features = ["serde"] }
chrono = { version = "0.4.23", features = ["serde"] }
clap = "2.33.0"
console = "0.15.0"
csv = "1.1.6"

View File

@ -218,11 +218,11 @@ mod tests {
#[test]
fn test_sort_transaction_infos_finalized_first() {
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()
};
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()
};
let info2 = TransactionInfo::default();