Struct primitives::sentry::DateHour
source · Expand description
DateHour
holds the date and hour (only).
It uses chrono::DateTime
when serializing and deserializing.
When serializing it always sets minutes and seconds to 0
(zero).
When deserializing the minutes and seconds should always be set to 0
(zero),
otherwise an error will be returned.
Fields
date: Date<Tz>
hour: u32
hour is in the range of 0 - 23
Implementations
sourceimpl DateHour<Utc>
impl DateHour<Utc>
sourcepub fn from_ymdh(year: i32, month: u32, day: u32, hour: u32) -> Self
pub fn from_ymdh(year: i32, month: u32, day: u32, hour: u32) -> Self
Panics
When wrong inputs have been passed, i.e. for year, month, day or hour.
sourcepub fn from_ymdh_opt(year: i32, month: u32, day: u32, hour: u32) -> Option<Self>
pub fn from_ymdh_opt(year: i32, month: u32, day: u32, hour: u32) -> Option<Self>
Makes a new DateHour
from year, month, day and hour.
Returns None
on invalid year, month, day or hour.
See chrono::NaiveDate::from_ymd_opt()
& chrono::NaiveTime::from_hms_opt()
for details
pub fn from_date_hour_opt(date: Date<Utc>, hour: u32) -> Option<Self>
pub fn now() -> Self
pub fn with_hour(&self, hour: u32) -> Option<Self>
pub fn with_day(&self, day: u32) -> Option<Self>
Trait Implementations
sourceimpl<'de> Deserialize<'de> for DateHour<Utc>
impl<'de> Deserialize<'de> for DateHour<Utc>
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
sourceimpl<'a> FromSql<'a> for DateHour<Utc>
impl<'a> FromSql<'a> for DateHour<Utc>
sourcefn from_sql(
ty: &PgType,
raw: &'a [u8]
) -> Result<Self, Box<dyn Error + Sync + Send>>
fn from_sql(
ty: &PgType,
raw: &'a [u8]
) -> Result<Self, Box<dyn Error + Sync + Send>>
Type
in its binary format. Read moresourcefn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type
. Read moresourceimpl<Tz: TimeZone> Ord for DateHour<Tz>
impl<Tz: TimeZone> Ord for DateHour<Tz>
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl<Tz: TimeZone, Tz2: TimeZone> PartialEq<DateHour<Tz2>> for DateHour<Tz>
impl<Tz: TimeZone, Tz2: TimeZone> PartialEq<DateHour<Tz2>> for DateHour<Tz>
sourceimpl<Tz: TimeZone, Tz2: TimeZone> PartialOrd<DateHour<Tz2>> for DateHour<Tz>
impl<Tz: TimeZone, Tz2: TimeZone> PartialOrd<DateHour<Tz2>> for DateHour<Tz>
sourcefn partial_cmp(&self, other: &DateHour<Tz2>) -> Option<Ordering>
fn partial_cmp(&self, other: &DateHour<Tz2>) -> Option<Ordering>
Compare two DateHours based on their true time, ignoring time zones
See DateTime
implementation of PartialOrd<DateTime<Tz2>>
for more details.
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl ToSql for DateHour<Utc>
impl ToSql for DateHour<Utc>
sourcefn to_sql(
&self,
ty: &PgType,
w: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql(
&self,
ty: &PgType,
w: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
self
into the binary format of the specified
Postgres Type
, appending it to out
. Read moresourcefn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type
. Read moresourcefn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
sourcefn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
impl<Tz: TimeZone> Copy for DateHour<Tz>where
Tz::Offset: Copy,
Manually implement Copy
as it requires a where clause for the TimeZone::Offset
impl<Tz: TimeZone> Eq for DateHour<Tz>
Auto Trait Implementations
impl<Tz> RefUnwindSafe for DateHour<Tz>where
<Tz as TimeZone>::Offset: RefUnwindSafe,
impl<Tz> Send for DateHour<Tz>where
<Tz as TimeZone>::Offset: Send,
impl<Tz> Sync for DateHour<Tz>where
<Tz as TimeZone>::Offset: Sync,
impl<Tz> Unpin for DateHour<Tz>where
<Tz as TimeZone>::Offset: Unpin,
impl<Tz> UnwindSafe for DateHour<Tz>where
<Tz as TimeZone>::Offset: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere
T: ToSql,
sourcefn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
self
as a ToSql
trait object.