stdweb::web

Struct Date

Source
pub struct Date(/* private fields */);
Expand description

(JavaScript docs) https://www.ecma-international.org/ecma-262/6.0/#sec-date-constructor

Implementations§

Source§

impl Date

Source

pub fn new() -> Self

Creates a JavaScript Date instance that represents a single moment in time. Date objects are based on a time value that is the number of milliseconds since 1 January 1970 UTC.

(JavaScript docs)

Source

pub fn from_datetime( year: i32, month: i32, day: i32, hours: i32, minutes: i32, seconds: i32, milliseconds: i32, ) -> Self

Creates a JavaScript Date instance that represents a single moment in time. Date objects are based on a time value that is the number of milliseconds since 1 January 1970 UTC.

year is an integer value representing the year. Values from 0 to 99 map to the years 1900 to 1999. month is an integer value representing the month, beginning with 0 for January to 11 for December day is an integer value representing the day of the month (normally from 1 to 31) hours an integer value representing the minute segment of a time seconds an integer value representing the second segment of a time milliseconds an integer value representing the millisecond segment of a time

(JavaScript docs)

Source

pub fn from_iso8601(date_string: &str) -> Self

Creates a JavaScript Date instance that represents a single moment in time. Date objects are based on a time value that is the number of milliseconds since 1 January 1970 UTC.

String value representing a date. The string should be in a format recognized by the Date.parse() method (IETF-compliant RFC 2822 timestamps and also a version of ISO8601).

(JavaScript docs)

Source

pub fn from_time(now: f64) -> Self

Creates a JavaScript Date instance that represents a single moment in time. Date objects are based on a time value that is the number of milliseconds since 1 January 1970 UTC.

Integer value representing the number of milliseconds since January 1, 1970, 00:00:00 UTC, with leap seconds ignored (Unix Epoch; but consider that most Unix timestamp functions count in seconds).

(JavaScript docs)

Source

pub fn utc( year: i32, month: i32, day: i32, hours: i32, minutes: i32, seconds: i32, milliseconds: i32, ) -> f64

The Date.UTC() method accepts the same parameters as the longest form of the constructor, and returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time.

(JavaScript docs)

Source

pub fn parse(date_string: &str) -> f64

The Date.parse() method parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC or NaN if the string is unrecognized or, in some cases, contains illegal date values (e.g. 2015-02-31).

(JavaScript docs)

Source

pub fn now() -> f64

The Date.now() method returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.

(JavaScript docs)

Source

pub fn get_date(&self) -> i32

The getDate() method returns the day of the month for the specified date according to local time.

(JavaScript docs)

Source

pub fn get_day(&self) -> i32

The getDay() method returns the day of the week for the specified date according to local time, where 0 represents Sunday. For the day of the month see getDate().

(JavaScript docs)

Source

pub fn get_full_year(&self) -> i32

The getFullYear() method returns the year of the specified date according to local time.

(JavaScript docs)

Source

pub fn get_hours(&self) -> i32

The getHours() method returns the hour for the specified date, according to local time.

(JavaScript docs)

Source

pub fn get_milliseconds(&self) -> i32

The getMilliseconds() method returns the milliseconds in the specified date according to local time.

(JavaScript docs)

Source

pub fn get_minutes(&self) -> i32

The getMinutes() method returns the minutes in the specified date according to local time.

(JavaScript docs)

Source

pub fn get_month(&self) -> i32

The getMonth() method returns the month in the specified date according to local time, as a zero-based value (where zero indicates the first month of the year).

(JavaScript docs)

Source

pub fn get_seconds(&self) -> i32

The getSeconds() method returns the seconds in the specified date according to local time.

(JavaScript docs)

Source

pub fn get_time(&self) -> f64

The getTime() method returns the numeric value corresponding to the time for the specified date according to universal time.

getTime() always uses UTC for time representation. For example, a client browser in one timezone, getTime() will be the same as a client browser in any other timezone.

You can use this method to help assign a date and time to another Date object. This method is functionally equivalent to the valueOf() method.

(JavaScript docs)

Source

pub fn get_timezone_offset(&self) -> i32

The getTimezoneOffset() method returns the time zone difference, in minutes, from current locale (host system settings) to UTC.

(JavaScript docs)

Source

pub fn get_utc_date(&self) -> i32

The getUTCDate() method returns the day (date) of the month in the specified date according to universal time.

(JavaScript docs)

Source

pub fn get_utc_day(&self) -> i32

The getUTCDay() method returns the day of the week in the specified date according to universal time, where 0 represents Sunday.

(JavaScript docs)

Source

pub fn get_utc_full_year(&self) -> i32

The getUTCFullYear() method returns the year in the specified date according to universal time.

(JavaScript docs)

Source

pub fn get_utc_hours(&self) -> i32

The getUTCHours() method returns the hours in the specified date according to universal time.

(JavaScript docs)

Source

pub fn get_utc_milliseconds(&self) -> i32

The getUTCMilliseconds() method returns the milliseconds in the specified date according to universal time.

(JavaScript docs)

Source

pub fn get_utc_minutes(&self) -> i32

The getUTCMinutes() method returns the minutes in the specified date according to universal time.

(JavaScript docs)

Source

pub fn get_utc_month(&self) -> i32

The getUTCMonth() returns the month of the specified date according to universal time, as a zero-based value (where zero indicates the first month of the year).

(JavaScript docs)

Source

pub fn get_utc_seconds(&self) -> i32

The getUTCSeconds() method returns the seconds in the specified date according to universal time.

(JavaScript docs)

Source

pub fn set_date(&self, date: i32)

The setDate() method sets the day of the Date object relative to the beginning of the currently set month.

(JavaScript docs)

Source

pub fn set_full_year(&self, full_year: i32)

The setFullYear() method sets the full year for a specified date according to local time. Returns new timestamp.

(JavaScript docs)

Source

pub fn set_hours(&self, hours: i32)

The setHours() method sets the hours for a specified date according to local time, and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented by the updated Date instance.

(JavaScript docs)

Source

pub fn set_milliseconds(&self, milliseconds: i32)

The setMilliseconds() method sets the milliseconds for a specified date according to local time.

(JavaScript docs)

Source

pub fn set_minutes(&self, minutes: i32)

The setMinutes() method sets the minutes for a specified date according to local time.

(JavaScript docs)

Source

pub fn set_month(&self, month: i32)

The setMonth() method sets the month for a specified date according to the currently set year.

(JavaScript docs)

Source

pub fn set_seconds(&self, seconds: i32)

The setSeconds() method sets the seconds for a specified date according to local time.

(JavaScript docs)

Source

pub fn set_time(&self, time: f64)

The setTime() method sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.

(JavaScript docs)

Source

pub fn set_utc_date(&self, date: i32)

The setUTCDate() method sets the day of the month for a specified date according to universal time.

(JavaScript docs)

Source

pub fn set_utc_full_year(&self, full_year: i32)

The setUTCFullYear() method sets the full year for a specified date according to universal time.

(JavaScript docs)

Source

pub fn set_utc_hours(&self, hours: i32)

The setUTCHours() method sets the hour for a specified date according to universal time, and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented by the updated Date instance.

(JavaScript docs)

Source

pub fn set_utc_milliseconds(&self, milliseconds: i32)

The setUTCMilliseconds() method sets the milliseconds for a specified date according to universal time.

(JavaScript docs)

Source

pub fn set_utc_minutes(&self, minutes: i32)

The setUTCMinutes() method sets the minutes for a specified date according to universal time.

(JavaScript docs)

Source

pub fn set_utc_month(&self, month: i32)

The setUTCMonth() method sets the month for a specified date according to universal time.

(JavaScript docs)

Source

pub fn set_utc_seconds(&self, seconds: i32)

The setUTCSeconds() method sets the seconds for a specified date according to universal time.

(JavaScript docs)

Source

pub fn to_date_string(&self) -> String

The toDateString() method returns the date portion of a Date object in human readable form in American English.

(JavaScript docs)

Source

pub fn to_iso_string(&self) -> String

The toISOString() method returns a string in simplified extended ISO format (ISO 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset, as denoted by the suffix “Z”.

(JavaScript docs)

Source

pub fn to_json(&self) -> String

The toJSON() method returns a string representation of the Date object.

(JavaScript docs)

Source

pub fn to_string(&self) -> String

The toString() method returns a string representing the specified Date object.

(JavaScript docs)

Source

pub fn to_time_string(&self) -> String

The toTimeString() method returns the time portion of a Date object in human readable form in American English.

(JavaScript docs)

Source

pub fn to_utc_string(&self) -> String

The toUTCString() method converts a date to a string, using the UTC time zone.

(JavaScript docs)

Source

pub fn value_of(&self) -> f64

The valueOf() method returns the primitive value of a Date object.

(JavaScript docs)

Trait Implementations§

Source§

impl AsRef<Reference> for Date

Source§

fn as_ref(&self) -> &Reference

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Date

Source§

fn clone(&self) -> Date

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 Date

Source§

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

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

impl From<Date> for Reference

Source§

fn from(value: Date) -> Self

Converts to this type from the input type.
Source§

impl InstanceOf for Date

Source§

fn instance_of(reference: &Reference) -> bool

Checks whenever a given Reference if of type Self.
Source§

impl PartialEq for Date

Source§

fn eq(&self, other: &Date) -> 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 ReferenceType for Date

Source§

unsafe fn from_reference_unchecked(reference: Reference) -> Self

Converts a given reference into a concrete reference-like wrapper. Doesn’t do any type checking; highly unsafe to use!
Source§

impl<'_r> TryFrom<&'_r Reference> for Date

Source§

type Error = ConversionError

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

fn try_from(reference: &Reference) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'_r> TryFrom<&'_r Value> for Date

Source§

type Error = ConversionError

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

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Date> for Reference

Source§

type Error = Void

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

fn try_from(value: Date) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Reference> for Date

Source§

type Error = ConversionError

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

fn try_from(reference: Reference) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Date

Source§

type Error = ConversionError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for Date

Source§

impl JsSerialize for Date

Source§

impl StructuralPartialEq for Date

Auto Trait Implementations§

§

impl Freeze for Date

§

impl RefUnwindSafe for Date

§

impl Send for Date

§

impl Sync for Date

§

impl Unpin for Date

§

impl UnwindSafe for Date

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.
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.