Trait ExtOffsetDateTime

Source
pub trait ExtOffsetDateTime {
Show 19 methods // Required methods fn is_same_minute(&self, b: &OffsetDateTime) -> bool; fn reset_minute(&self) -> OffsetDateTime; fn milli_timestamp(&self) -> i64; fn to_display_string(&self, offset_hours: i8) -> String; fn to_chinese_string(&self) -> String; fn from_milliseconds( timestamp: u64, offset_hours: i8, ) -> Result<OffsetDateTime, OffsetDateTimeError>; fn from_seconds( timestamp: u64, offset_hours: i8, ) -> Result<OffsetDateTime, OffsetDateTimeError>; fn from_date_time( date: &str, time: &str, milli: u64, offset_hours: i8, ) -> Result<OffsetDateTime, OffsetDateTimeError>; fn from_simple( dt: &str, offset_hours: i8, ) -> Result<OffsetDateTime, OffsetDateTimeError>; fn convert_to_dot_date(input: &str) -> Result<String, OffsetDateTimeError>; fn replace_time_with_seconds( &self, seconds: i64, ) -> Result<OffsetDateTime, OffsetDateTimeError>; fn align_to( &self, interval: i64, ) -> Result<OffsetDateTime, OffsetDateTimeError>; fn next_day(&self) -> OffsetDateTime; fn next_hour(&self) -> OffsetDateTime; fn next_minute(&self) -> OffsetDateTime; fn next_second(&self) -> OffsetDateTime; fn to_hour_seconds(&self) -> i64; fn to_minute_seconds(&self) -> i64; // Provided method fn now_with_offset(offset_hours: i8) -> OffsetDateTime { ... }
}

Required Methods§

Source

fn is_same_minute(&self, b: &OffsetDateTime) -> bool

Check if two timestamps are in the same minute

Source

fn reset_minute(&self) -> OffsetDateTime

Reset seconds and subseconds to zero

Source

fn milli_timestamp(&self) -> i64

Get timestamp in milliseconds

Source

fn to_display_string(&self, offset_hours: i8) -> String

Format datetime to display string with timezone

Source

fn to_chinese_string(&self) -> String

Format datetime to Chinese style string with timezone

Source

fn from_milliseconds( timestamp: u64, offset_hours: i8, ) -> Result<OffsetDateTime, OffsetDateTimeError>

Parse timestamp in milliseconds with timezone offset (hours from UTC)

Source

fn from_seconds( timestamp: u64, offset_hours: i8, ) -> Result<OffsetDateTime, OffsetDateTimeError>

Parse timestamp in seconds with timezone offset (hours from UTC)

Source

fn from_date_time( date: &str, time: &str, milli: u64, offset_hours: i8, ) -> Result<OffsetDateTime, OffsetDateTimeError>

Parse datetime from date string, time string and milliseconds with timezone

Source

fn from_simple( dt: &str, offset_hours: i8, ) -> Result<OffsetDateTime, OffsetDateTimeError>

Parse datetime from simple format string (YYYYMMDD_HHMM) with timezone

Source

fn convert_to_dot_date(input: &str) -> Result<String, OffsetDateTimeError>

Convert date format from YYYYMMDD to YYYY.MM.DD

Source

fn replace_time_with_seconds( &self, seconds: i64, ) -> Result<OffsetDateTime, OffsetDateTimeError>

Replace time part with seconds (hours + minutes + seconds)

§Arguments
  • seconds - Total seconds (hours * 3600 + minutes * 60 + seconds)
§Returns
  • Ok(OffsetDateTime) - DateTime with new time part
  • Err - If seconds value is invalid
Source

fn align_to(&self, interval: i64) -> Result<OffsetDateTime, OffsetDateTimeError>

Align time to the nearest interval

§Arguments
  • interval - Interval in seconds (can be negative for backward alignment)
§Returns
  • Ok(OffsetDateTime) - Aligned time
  • Err(Error) - If interval is 0
Source

fn next_day(&self) -> OffsetDateTime

Get next day at the same time

Source

fn next_hour(&self) -> OffsetDateTime

Get next hour at the same minute and second

Source

fn next_minute(&self) -> OffsetDateTime

Get next minute at the same second

Source

fn next_second(&self) -> OffsetDateTime

Get next second

Source

fn to_hour_seconds(&self) -> i64

Convert time part to seconds, ignoring minutes and seconds

§Returns

Total seconds of hours (hours * 3600)

Note: Returns i64 to support time differences and negative values

Source

fn to_minute_seconds(&self) -> i64

Convert time part to seconds, ignoring seconds

§Returns

Total seconds of hours and minutes (hours * 3600 + minutes * 60)

Note: Returns i64 to support time differences and negative values

Provided Methods§

Source

fn now_with_offset(offset_hours: i8) -> OffsetDateTime

Get current time with specified timezone offset (hours from UTC)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§