pub struct DateHelper;Expand description
Date/time helpers
Implementations§
Source§impl DateHelper
impl DateHelper
Sourcepub fn time_ago(date: &NaiveDateTime) -> String
pub fn time_ago(date: &NaiveDateTime) -> String
Human-readable “time ago” string (French)
Sourcepub fn format(date: &NaiveDateTime, fmt: &str) -> String
pub fn format(date: &NaiveDateTime, fmt: &str) -> String
Format a NaiveDateTime with the given chrono format string
Sourcepub fn format_fr(date: &NaiveDateTime) -> String
pub fn format_fr(date: &NaiveDateTime) -> String
Format as “dd/mm/YYYY”
Sourcepub fn format_fr_time(date: &NaiveDateTime) -> String
pub fn format_fr_time(date: &NaiveDateTime) -> String
Format as “dd/mm/YYYY HH:MM”
Sourcepub fn format_iso(date: &NaiveDateTime) -> String
pub fn format_iso(date: &NaiveDateTime) -> String
Format as “YYYY-MM-DD”
Sourcepub fn format_iso_time(date: &NaiveDateTime) -> String
pub fn format_iso_time(date: &NaiveDateTime) -> String
Format as “YYYY-MM-DD HH:MM:SS”
Sourcepub fn is_past(date: &NaiveDateTime) -> bool
pub fn is_past(date: &NaiveDateTime) -> bool
Check if a datetime is in the past
Sourcepub fn is_future(date: &NaiveDateTime) -> bool
pub fn is_future(date: &NaiveDateTime) -> bool
Check if a datetime is in the future
Sourcepub fn diff_in_days(from: &NaiveDateTime, to: &NaiveDateTime) -> i64
pub fn diff_in_days(from: &NaiveDateTime, to: &NaiveDateTime) -> i64
Difference in days between two dates
Sourcepub fn diff_in_hours(from: &NaiveDateTime, to: &NaiveDateTime) -> i64
pub fn diff_in_hours(from: &NaiveDateTime, to: &NaiveDateTime) -> i64
Difference in hours between two datetimes
Sourcepub fn diff_in_minutes(from: &NaiveDateTime, to: &NaiveDateTime) -> i64
pub fn diff_in_minutes(from: &NaiveDateTime, to: &NaiveDateTime) -> i64
Difference in minutes between two datetimes
Sourcepub fn now() -> NaiveDateTime
pub fn now() -> NaiveDateTime
Get the current UTC datetime
Sourcepub fn start_of_day(date: &NaiveDate) -> NaiveDateTime
pub fn start_of_day(date: &NaiveDate) -> NaiveDateTime
Get the start of the day (00:00:00)
Sourcepub fn end_of_day(date: &NaiveDate) -> NaiveDateTime
pub fn end_of_day(date: &NaiveDate) -> NaiveDateTime
Get the end of the day (23:59:59)
Auto Trait Implementations§
impl Freeze for DateHelper
impl RefUnwindSafe for DateHelper
impl Send for DateHelper
impl Sync for DateHelper
impl Unpin for DateHelper
impl UnsafeUnpin for DateHelper
impl UnwindSafe for DateHelper
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn propagate_header(self, header: HeaderName) -> PropagateHeader<Self>where
Self: Sized,
fn propagate_header(self, header: HeaderName) -> PropagateHeader<Self>where
Self: Sized,
Propagate a header from the request to the response. Read more
Source§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
Compresses response bodies. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Insert a header into the request. Read more
Source§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Append a header into the request. Read more
Source§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Insert a header into the request, if the header is not already present. Read more
Source§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Insert a header into the response. Read more
Source§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Append a header into the response. Read more
Source§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Insert a header into the response, if the header is not already present. Read more
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Add request id header and extension. Read more
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Add request id header and extension, using
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Propgate request ids from requests to responses. Read more
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
Propgate request ids from requests to responses, using
x-request-id as the header name. Read moreSource§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
Intercept requests with over-sized payloads and convert them into
413 Payload Too Large responses. Read more