Skip to main content

DateTime

Struct DateTime 

Source
#[non_exhaustive]
pub struct DateTime { pub day: Option<i32>, pub hours: Option<i32>, pub minutes: Option<i32>, pub month: Option<i32>, pub nanos: Option<i32>, pub seconds: Option<i32>, pub time_zone: Option<TimeZone>, pub utc_offset: Option<Duration>, pub year: Option<i32>, /* private fields */ }
Available on crate features region-zones or zones only.
Expand description

Represents civil time (or occasionally physical time).

This type can represent a civil time in one of a few possible ways:

  • When utc_offset is set and time_zone is unset: a civil time on a calendar day with a particular offset from UTC.
  • When time_zone is set and utc_offset is unset: a civil time on a calendar day in a particular time zone.
  • When neither time_zone nor utc_offset is set: a civil time on a calendar day in local time.

The date is relative to the Proleptic Gregorian Calendar.

If year, month, or day are 0, the DateTime is considered not to have a specific year, month, or day respectively.

This type may also be used to represent a physical time if all the date and time fields are set and either case of the time_offset oneof is set. Consider using Timestamp message for physical time instead. If your use case also would like to store the user’s timezone, that can be done in another field.

This type is more flexible than some applications may want. Make sure to document and validate your application’s limitations.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§day: Option<i32>

Optional. Day of month. Must be from 1 to 31 and valid for the year and month, or 0 if specifying a datetime without a day.

§hours: Option<i32>

Optional. Hours of day in 24 hour format. Should be from 0 to 23, defaults to 0 (midnight). An API may choose to allow the value “24:00:00” for scenarios like business closing time.

§minutes: Option<i32>

Optional. Minutes of hour of day. Must be from 0 to 59, defaults to 0.

§month: Option<i32>

Optional. Month of year. Must be from 1 to 12, or 0 if specifying a datetime without a month.

§nanos: Option<i32>

Optional. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999, defaults to 0.

§seconds: Option<i32>

Optional. Seconds of minutes of the time. Must normally be from 0 to 59, defaults to 0. An API may allow the value 60 if it allows leap-seconds.

§time_zone: Option<TimeZone>

Time zone.

§utc_offset: Option<Duration>

UTC offset. Must be whole seconds, between -18 hours and +18 hours. For example, a UTC offset of -4:00 would be represented as { seconds: -14400 }.

§year: Option<i32>

Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year.

Implementations§

Source§

impl DateTime

Source

pub fn new() -> Self

Creates a new default instance.

Source

pub fn set_day<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of day.

§Example
let x = DateTime::new().set_day(42);
Source

pub fn set_or_clear_day<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of day.

§Example
let x = DateTime::new().set_or_clear_day(Some(42));
let x = DateTime::new().set_or_clear_day(None::<i32>);
Source

pub fn set_hours<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of hours.

§Example
let x = DateTime::new().set_hours(42);
Source

pub fn set_or_clear_hours<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of hours.

§Example
let x = DateTime::new().set_or_clear_hours(Some(42));
let x = DateTime::new().set_or_clear_hours(None::<i32>);
Source

pub fn set_minutes<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of minutes.

§Example
let x = DateTime::new().set_minutes(42);
Source

pub fn set_or_clear_minutes<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of minutes.

§Example
let x = DateTime::new().set_or_clear_minutes(Some(42));
let x = DateTime::new().set_or_clear_minutes(None::<i32>);
Source

pub fn set_month<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of month.

§Example
let x = DateTime::new().set_month(42);
Source

pub fn set_or_clear_month<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of month.

§Example
let x = DateTime::new().set_or_clear_month(Some(42));
let x = DateTime::new().set_or_clear_month(None::<i32>);
Source

pub fn set_nanos<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of nanos.

§Example
let x = DateTime::new().set_nanos(42);
Source

pub fn set_or_clear_nanos<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of nanos.

§Example
let x = DateTime::new().set_or_clear_nanos(Some(42));
let x = DateTime::new().set_or_clear_nanos(None::<i32>);
Source

pub fn set_seconds<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of seconds.

§Example
let x = DateTime::new().set_seconds(42);
Source

pub fn set_or_clear_seconds<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of seconds.

§Example
let x = DateTime::new().set_or_clear_seconds(Some(42));
let x = DateTime::new().set_or_clear_seconds(None::<i32>);
Source

pub fn set_time_zone<T>(self, v: T) -> Self
where T: Into<TimeZone>,

Sets the value of time_zone.

§Example
use google_cloud_compute_v1::model::TimeZone;
let x = DateTime::new().set_time_zone(TimeZone::default()/* use setters */);
Source

pub fn set_or_clear_time_zone<T>(self, v: Option<T>) -> Self
where T: Into<TimeZone>,

Sets or clears the value of time_zone.

§Example
use google_cloud_compute_v1::model::TimeZone;
let x = DateTime::new().set_or_clear_time_zone(Some(TimeZone::default()/* use setters */));
let x = DateTime::new().set_or_clear_time_zone(None::<TimeZone>);
Source

pub fn set_utc_offset<T>(self, v: T) -> Self
where T: Into<Duration>,

Sets the value of utc_offset.

§Example
use wkt::Duration;
let x = DateTime::new().set_utc_offset(Duration::default()/* use setters */);
Source

pub fn set_or_clear_utc_offset<T>(self, v: Option<T>) -> Self
where T: Into<Duration>,

Sets or clears the value of utc_offset.

§Example
use wkt::Duration;
let x = DateTime::new().set_or_clear_utc_offset(Some(Duration::default()/* use setters */));
let x = DateTime::new().set_or_clear_utc_offset(None::<Duration>);
Source

pub fn set_year<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of year.

§Example
let x = DateTime::new().set_year(42);
Source

pub fn set_or_clear_year<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of year.

§Example
let x = DateTime::new().set_or_clear_year(Some(42));
let x = DateTime::new().set_or_clear_year(None::<i32>);

Trait Implementations§

Source§

impl Clone for DateTime

Source§

fn clone(&self) -> DateTime

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DateTime

Source§

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

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

impl Default for DateTime

Source§

fn default() -> DateTime

Returns the “default value” for a type. Read more
Source§

impl Message for DateTime

Source§

fn typename() -> &'static str

The typename of this message.
Source§

impl PartialEq for DateTime

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for DateTime

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more