Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, this is another deprecation other than the move from internal panic in chrono: chronotope/chrono#851

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that DateConfig isn't used at all as our ci shows this api change affects no other code in our monorepo.

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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ homepage = "https://solana.com/"
documentation = "https://docs.rs/solana-tokens"

[dependencies]
chrono = { version = "0.4", features = ["serde"] }
Copy link
Copy Markdown
Contributor Author

@ryoqun ryoqun Jan 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this Cargo.toml update is unavoidable because of the need to use .with_ymd_and_hms(), which is added in v0.4.23.

Intentionally, I avoided to bump version in other Cargo.tomls to avoid downstream chrono update churn en masse, including solana-sdk. As long as we don't use newer fn like solana-tokens. this should be safe.

Conversely, it looks like users are starting to use chrono v0.4.23: #29109

that said, i think this particular Cargo.toml update should be harmless, considering this crate is virtually unused as other deps: https://crates.io/crates/solana-tokens/reverse_dependencies

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe I can bump the others in another PR. (I would like to make packages use the same version of deps when they are under the same workspace so I force all of them align to 0.4.22 in my workspace inheritance PR)

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
Original file line number Diff line number Diff line change
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