Skip to content

Commit

Permalink
Bump chrono to v0.4.23 (#29709)
Browse files Browse the repository at this point in the history
* Bump chrono to v0.4.23

* fmt...
  • Loading branch information
ryoqun committed Jan 18, 2023
1 parent 29ed19c commit 254381e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion cli-output/src/cli_output.rs
Expand Up @@ -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:?}")?;
Expand Down
4 changes: 2 additions & 2 deletions cli-output/src/display.rs
Expand Up @@ -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}",)?;
}
Expand Down
4 changes: 3 additions & 1 deletion install/src/command.rs
Expand Up @@ -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:"),
Expand Down
14 changes: 6 additions & 8 deletions programs/config/src/date_instruction.rs
Expand Up @@ -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},
Expand All @@ -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> {
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion tokens/Cargo.toml
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions tokens/src/db.rs
Expand Up @@ -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();
Expand Down

0 comments on commit 254381e

Please sign in to comment.