Enable access to timestamps for directives
Dependencies
- [2]
4UOASAH3Make Acc and AccountTemplate zero-copy deserializable - [3]
SEEWF7KXImplement metadata on transactions - [4]
W3MWSSJ7Add a templating engine for accounts - [*]
YDK6X6PPadd a library of important types for beancount - [*]
T2S6UAVJInclude builder methods on beancount-types - [*]
2JBFREZGenable additional warnings - [*]
R7S2CWF7Add type for account segments - [*]
UESS5YZEmigrate dependencies into workspace manifest
Change contents
- edit in common/beancount-types/src/transaction.rs at line 8
use time::format_description::well_known::Rfc3339; - edit in common/beancount-types/src/transaction.rs at line 10
use time::OffsetDateTime; - edit in common/beancount-types/src/transaction.rs at line 293
impl Transaction {#[inline]pub fn timestamp(&self) -> Option<OffsetDateTime> {self.metadata.key_value.get("timestamp").and_then(MetadataValue::as_str).and_then(|timestamp| OffsetDateTime::parse(timestamp, &Rfc3339).ok())}} - edit in common/beancount-types/src/metadata.rs at line 17
}impl Key {pub const unsafe fn from_unchecked(name: String) -> Self {Self { name }}}impl Borrow<str> for Key {fn borrow(&self) -> &str {&self.name} - replacement in common/beancount-types/src/metadata.rs at line 200
link.fmt(f)?write!(f, "\n {link}")?;}for (key, value) in &self.key_value {write!(f, "\n {key}: {value}")?; - edit in common/beancount-types/src/metadata.rs at line 214
}impl Value {pub fn as_str(&self) -> Option<&str> {let Self::String(inner) = self;Some(inner)} - edit in common/beancount-types/src/lib.rs at line 1
#![warn(clippy::all, clippy::pedantic)] - edit in common/beancount-types/src/lib.rs at line 27
use time::OffsetDateTime; - edit in common/beancount-types/src/lib.rs at line 58
}}pub fn timestamp(&self) -> Option<OffsetDateTime> {match self {Directive::Balance(balance) => balance.timestamp(),Directive::Transaction(transaction) => transaction.timestamp(), - edit in common/beancount-types/src/balance.rs at line 5
use time::OffsetDateTime;use time_tz::PrimitiveDateTimeExt; - edit in common/beancount-types/src/balance.rs at line 20
impl Balance {#[inline]pub fn timestamp(&self) -> Option<OffsetDateTime> {// Balance statements occur first thing in the daylet local_timestamp = self.date.midnight();let timezone = time_tz::system::get_timezone().ok()?;local_timestamp.assume_timezone(timezone).take_first()}} - edit in common/beancount-types/src/account/template.rs at line 7
use serde::Deserializer; - replacement in common/beancount-types/src/account/template.rs at line 123
account.join(&segment)account.join(segment) - edit in common/beancount-types/Cargo.toml at line 23[10.456][6.26127]
time-tz.workspace = true