persistent_time

Struct Time

Source
pub struct Time { /* private fields */ }

Implementations§

Source§

impl Time

Source

pub fn new() -> Self

Methods from Deref<Target = DateTime<Local>>§

Source

pub fn date(&self) -> Date<Tz>

Retrieves a date component.

Source

pub fn time(&self) -> NaiveTime

Retrieves a time component. Unlike date, this is not associated to the time zone.

Source

pub fn timestamp(&self) -> i64

Returns the number of non-leap seconds since January 1, 1970 0:00:00 UTC (aka “UNIX timestamp”).

Source

pub fn timestamp_subsec_millis(&self) -> u32

Returns the number of milliseconds since the last second boundary

warning: in event of a leap second, this may exceed 999

note: this is not the number of milliseconds since January 1, 1970 0:00:00 UTC

Source

pub fn timestamp_subsec_micros(&self) -> u32

Returns the number of microseconds since the last second boundary

warning: in event of a leap second, this may exceed 999_999

note: this is not the number of microseconds since January 1, 1970 0:00:00 UTC

Source

pub fn timestamp_subsec_nanos(&self) -> u32

Returns the number of nanoseconds since the last second boundary

warning: in event of a leap second, this may exceed 999_999_999

note: this is not the number of nanoseconds since January 1, 1970 0:00:00 UTC

Source

pub fn num_seconds_from_unix_epoch(&self) -> i64

Deprecated: Same to DateTime::timestamp.

Source

pub fn offset<'a>(&'a self) -> &'a <Tz as TimeZone>::Offset

Retrieves an associated offset from UTC.

Source

pub fn timezone(&self) -> Tz

Retrieves an associated time zone.

Source

pub fn with_timezone<Tz2>(&self, tz: &Tz2) -> DateTime<Tz2>
where Tz2: TimeZone,

Changes the associated time zone. This does not change the actual DateTime (but will change the string representation).

Source

pub fn naive_utc(&self) -> NaiveDateTime

Returns a view to the naive UTC datetime.

Source

pub fn naive_local(&self) -> NaiveDateTime

Returns a view to the naive local datetime.

Source

pub fn to_rfc2822(&self) -> String

Returns an RFC 2822 date and time string such as Tue, 1 Jul 2003 10:52:37 +0200.

Source

pub fn to_rfc3339(&self) -> String

Returns an RFC 3339 and ISO 8601 date and time string such as 1996-12-19T16:39:57-08:00.

Source

pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat<I>
where I: Iterator<Item = Item<'a>> + Clone,

Formats the combined date and time with the specified formatting items.

Source

pub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>>

Formats the combined date and time with the specified format string. See the format::strftime module on the supported escape sequences.

Trait Implementations§

Source§

impl Clone for Time

Source§

fn clone(&self) -> Time

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Time

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Decodable for Time

Source§

fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error>

Deserialize a value using a Decoder.
Source§

impl Deref for Time

Source§

type Target = DateTime<Local>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &DateTime<Local>

Dereferences the value.
Source§

impl Encodable for Time

Source§

fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error>

Serialize a value using an Encoder.
Source§

impl FromRedisValue for Time

Source§

fn from_redis_value(v: &Value) -> RedisResult<Self>

Given a redis Value this attempts to convert it into the given destination type. If that fails because it’s not compatible an appropriate error is generated.
Source§

fn from_redis_values(items: &[Value]) -> Result<Vec<Self>, RedisError>

Similar to from_redis_value but constructs a vector of objects from another vector of values. This primarily exists internally to customize the behavior for vectors of tuples.
Source§

impl FromSql for Time

Source§

fn from_sql<R: Read>( ty: &Type, raw: &mut R, ctx: &SessionInfo<'_>, ) -> Result<Time>

Creates a new value of this type from a Reader of the binary format of the specified Postgres Type. Read more
Source§

fn accepts(_: &Type) -> bool

Determines if a value of this type can be created from the specified Postgres Type.
Source§

fn from_sql_null(ty: &Type, ctx: &SessionInfo<'_>) -> Result<Self, Error>

Creates a new value of this type from a NULL SQL value. Read more
Source§

impl PartialEq for Time

Source§

fn eq(&self, other: &Time) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToRedisArgs for Time

Source§

fn to_redis_args(&self) -> Vec<Vec<u8>>

This converts the value into a vector of bytes. Each item is a single argument. Most items generate a vector of a single item. Read more
Source§

fn describe_numeric_behavior(&self) -> NumericBehavior

Returns an information about the contained value with regards to it’s numeric behavior in a redis context. This is used in some high level concepts to switch between different implementations of redis functions (for instance INCR vs INCRBYFLOAT).
Source§

fn is_single_arg(&self) -> bool

Returns an indiciation if the value contained is exactly one argument. It returns false if it’s zero or more than one. This is used in some high level functions to intelligently switch between GET and MGET variants.
Source§

impl ToSql for Time

Source§

fn to_sql<W: Write + ?Sized>( &self, ty: &Type, w: &mut W, ctx: &SessionInfo<'_>, ) -> Result<IsNull>

Converts the value of self into the binary format of the specified Postgres Type, writing it to out. Read more
Source§

fn accepts(_: &Type) -> bool

Determines if a value of this type can be converted to the specified Postgres Type.
Source§

fn to_sql_checked( &self, ty: &Type, out: &mut dyn Write, ctx: &SessionInfo<'_>, ) -> Result<IsNull>

An adaptor method used internally by Rust-Postgres. Read more
Source§

impl Copy for Time

Source§

impl Eq for Time

Source§

impl StructuralPartialEq for Time

Auto Trait Implementations§

§

impl Freeze for Time

§

impl RefUnwindSafe for Time

§

impl Send for Time

§

impl Sync for Time

§

impl Unpin for Time

§

impl UnwindSafe for Time

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.