pub struct TimestampFormatter { /* private fields */ }Expand description
Timestamp formatter for converting millisecond timestamps to strings.
§Examples
use kalam_client::timestamp::{TimestampFormat, TimestampFormatter};
let formatter = TimestampFormatter::new(TimestampFormat::Iso8601);
let formatted = formatter.format(Some(1734211234567));
assert_eq!(formatted, "2024-12-14T21:20:34.567Z");Implementations§
Source§impl TimestampFormatter
impl TimestampFormatter
Sourcepub fn new(format: TimestampFormat) -> TimestampFormatter
pub fn new(format: TimestampFormat) -> TimestampFormatter
Create a new timestamp formatter with the specified format.
Sourcepub fn format(&self, ms: Option<i64>) -> String
pub fn format(&self, ms: Option<i64>) -> String
Format a millisecond timestamp according to the configured format.
Returns “NULL” for None values.
Sourcepub fn format_relative(&self, ms: i64) -> String
pub fn format_relative(&self, ms: i64) -> String
Format as relative time: 2 hours ago, in 5 minutes
Trait Implementations§
Source§impl Clone for TimestampFormatter
impl Clone for TimestampFormatter
Source§fn clone(&self) -> TimestampFormatter
fn clone(&self) -> TimestampFormatter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TimestampFormatter
impl Debug for TimestampFormatter
Source§impl Default for TimestampFormatter
impl Default for TimestampFormatter
Source§fn default() -> TimestampFormatter
fn default() -> TimestampFormatter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TimestampFormatter
impl RefUnwindSafe for TimestampFormatter
impl Send for TimestampFormatter
impl Sync for TimestampFormatter
impl Unpin for TimestampFormatter
impl UnsafeUnpin for TimestampFormatter
impl UnwindSafe for TimestampFormatter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more