Skip to content

Commit 308a268

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 7166986 commit 308a268

File tree

1 file changed

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

1 file changed

+11
-0
lines changed

lightning-liquidity/src/lsps0/ser.rs

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

240251
impl FromStr for LSPSDateTime {

0 commit comments

Comments
 (0)