Skip to content

Commit

Permalink
Document the accuracy of the ledger timestamp (#1289)
Browse files Browse the repository at this point in the history
### What
Document the accuracy of the ledger timestamp.

### Why
It's important that the accuracy is known by developers relying on the
timestamp for certain use cases. The update here is taken from a recent
update in the Stellar docs and communicates the same.

Related stellar/stellar-docs#509
Related stellar/stellar-docs#572

Close #1258
  • Loading branch information
leighmcculloch authored Jul 16, 2024
1 parent 9c91852 commit 1f10e9a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions soroban-sdk/src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use crate::{env::internal, unwrap::UnwrapInfallible, BytesN, Env, TryIntoVal};

/// Ledger retrieves information about the current ledger.
///
/// For more details about the ledger and the ledger header that the values in the Ledger are derived from, see:
/// - https://developers.stellar.org/docs/learn/encyclopedia/network-configuration/ledger-headers
///
/// ### Examples
///
/// ```
Expand Down Expand Up @@ -75,9 +78,12 @@ impl Ledger {

/// Returns a unix timestamp for when the ledger was closed.
///
/// The timestamp is the number of seconds, excluding leap seconds,
/// that have elapsed since unix epoch. Unix epoch is January 1st, 1970,
/// at 00:00:00 UTC.
/// The timestamp is the number of seconds, excluding leap seconds, that
/// have elapsed since unix epoch. Unix epoch is January 1st, 1970, at
/// 00:00:00 UTC.
///
/// For more details see:
/// - https://developers.stellar.org/docs/learn/encyclopedia/network-configuration/ledger-headers#close-time
pub fn timestamp(&self) -> u64 {
internal::Env::get_ledger_timestamp(self.env())
.unwrap_infallible()
Expand Down

0 comments on commit 1f10e9a

Please sign in to comment.