Skip to content

Commit 8241eb0

Browse files
fixup: add timestamp and now helpers to LSPSDateTime
Add helper methods to LSPSDateTime that return the timestamp as seconds and as milliseconds since the Unix epoch. These methods improve consistency in date-time conversions.
1 parent f1e2937 commit 8241eb0

File tree

1 file changed

+10
-0
lines changed
  • lightning-liquidity/src/lsps0

1 file changed

+10
-0
lines changed

lightning-liquidity/src/lsps0/ser.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,16 @@ impl LSPSDateTime {
236236
self.0.timestamp().try_into().expect("expiration to be ahead of unix epoch");
237237
now_seconds_since_epoch > datetime_seconds_since_epoch
238238
}
239+
240+
/// Returns the timestamp as seconds since the Unix epoch.
241+
pub fn timestamp(&self) -> i64 {
242+
self.0.timestamp()
243+
}
244+
245+
/// Returns the timestamp as milliseconds since the Unix epoch.
246+
pub fn now() -> Self {
247+
Self(chrono::Utc::now())
248+
}
239249
}
240250

241251
impl FromStr for LSPSDateTime {

0 commit comments

Comments
 (0)