Date

Struct Date 

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

Implementations§

Source§

impl Date

Source

pub fn time_clip(time: f64) -> Option<f64>

Check if the time (number of milliseconds) is in the expected range. Returns None if the time is not in the range, otherwise returns the time itself in option.

More information:

Source

pub fn to_local(self) -> Option<DateTime<Local>>

Converts the Date to a local DateTime.

If the Date is invalid (i.e. NAN), this function will return None.

Source

pub fn to_utc(self) -> Option<DateTime<Utc>>

Converts the Date to a UTC DateTime.

If the Date is invalid (i.e. NAN), this function will return None.

Source

pub fn set_components( &mut self, utc: bool, year: Option<f64>, month: Option<f64>, day: Option<f64>, hour: Option<f64>, minute: Option<f64>, second: Option<f64>, millisecond: Option<f64>, )

Optionally sets the individual components of the Date.

Each component does not have to be within the range of valid values. For example, if month is too large then year will be incremented by the required amount.

Source

pub fn get_date(&self) -> f64

Date.prototype.getDate()

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

More information:

Source

pub fn get_day(&self) -> f64

Date.prototype.getDay()

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

More information:

Source

pub fn get_full_year(&self) -> f64

Date.prototype.getFullYear()

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

More information:

Source

pub fn get_hours(&self) -> f64

Date.prototype.getHours()

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

More information:

Source

pub fn get_milliseconds(&self) -> f64

Date.prototype.getMilliseconds()

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

More information:

Source

pub fn get_minutes(&self) -> f64

Date.prototype.getMinutes()

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

More information:

Source

pub fn get_month(&self) -> f64

Date.prototype.getMonth()

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

More information:

Source

pub fn get_seconds(&self) -> f64

Date.prototype.getSeconds()

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

More information:

Source

pub fn get_year(&self) -> f64

Date.prototype.getYear()

The getYear() method returns the year in the specified date according to local time. Because getYear() does not return full years (“year 2000 problem”), it is no longer used and has been replaced by the getFullYear() method.

More information:

Source

pub fn get_time(&self) -> f64

Date.prototype.getTime()

The getTime() method returns the number of milliseconds since the Unix Epoch.

More information:

Source

pub fn get_timezone_offset( this: &JsValue, _: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.getTimeZoneOffset()

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

More information:

Source

pub fn get_utc_date(&self) -> f64

Date.prototype.getUTCDate()

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

More information:

Source

pub fn get_utc_day(&self) -> f64

Date.prototype.getUTCDay()

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

More information:

Source

pub fn get_utc_full_year(&self) -> f64

Date.prototype.getUTCFullYear()

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

More information:

Source

pub fn get_utc_hours(&self) -> f64

Date.prototype.getUTCHours()

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

More information:

Source

pub fn get_utc_milliseconds(&self) -> f64

Date.prototype.getUTCMilliseconds()

The getUTCMilliseconds() method returns the milliseconds portion of the time object’s value.

More information:

Source

pub fn get_utc_minutes(&self) -> f64

Date.prototype.getUTCMinutes()

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

More information:

Source

pub fn get_utc_month(&self) -> f64

Date.prototype.getUTCMonth()

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

More information:

Source

pub fn get_utc_seconds(&self) -> f64

Date.prototype.getUTCSeconds()

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

More information:

Source

pub fn set_date( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setDate()

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

More information:

Source

pub fn set_full_year( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setFullYear()

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

More information:

Source

pub fn set_hours( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setHours()

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.

More information:

Source

pub fn set_milliseconds( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setMilliseconds()

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

More information:

Source

pub fn set_minutes( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setMinutes()

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

More information:

Source

pub fn set_month( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setMonth()

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

More information:

Source

pub fn set_seconds( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setSeconds()

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

More information:

Source

pub fn set_year( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setYear()

The setYear() method sets the year for a specified date according to local time.

More information:

Source

pub fn set_time( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setTime()

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

More information:

Source

pub fn set_utc_date( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setUTCDate()

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

More information:

Source

pub fn set_utc_full_year( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setFullYear()

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

More information:

Source

pub fn set_utc_hours( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setUTCHours()

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.

More information:

Source

pub fn set_utc_milliseconds( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setUTCMilliseconds()

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

More information:

Source

pub fn set_utc_minutes( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setUTCMinutes()

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

More information:

Source

pub fn set_utc_month( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setUTCMonth()

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

More information:

Source

pub fn set_utc_seconds( this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.setUTCSeconds()

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

More information:

Source

pub fn to_date_string( this: &JsValue, _: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.toDateString()

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

More information:

Source

pub fn to_gmt_string(self) -> String

Date.prototype.toGMTString()

The toGMTString() method converts a date to a string, using Internet Greenwich Mean Time (GMT) conventions.

More information:

Source

pub fn to_iso_string( this: &JsValue, _: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.toISOString()

The toISOString() method returns a string in simplified extended ISO format (ISO 8601).

More information:

Source

pub fn to_json( this: &JsValue, _: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.toJSON()

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

More information:

Source

pub fn to_string( this: &JsValue, _: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.toString()

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

More information:

Source

pub fn to_time_string( this: &JsValue, _: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Date.prototype.toTimeString()

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

More information:

Source

pub fn to_utc_string(self) -> String

Date.prototype.toUTCString()

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

More information:

Source

pub fn value_of(&self) -> f64

Date.prototype.valueOf()

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

More information:

Trait Implementations§

Source§

impl Clone for Date

Source§

fn clone(&self) -> Date

Returns a duplicate 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 Default for Date

Source§

fn default() -> Self

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

impl Display for Date

Source§

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

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

impl Finalize for Date

Source§

impl Hash for Date

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Date

Source§

fn cmp(&self, other: &Date) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
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 PartialOrd for Date

Source§

fn partial_cmp(&self, other: &Date) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Trace for Date

Source§

unsafe fn trace(&self)

Marks all contained Gcs.
Source§

unsafe fn root(&self)

Increments the root-count of all contained Gcs.
Source§

unsafe fn unroot(&self)

Decrements the root-count of all contained Gcs.
Source§

fn finalize_glue(&self)

Runs Finalize::finalize() on this object and all contained subobjects
Source§

impl Copy for Date

Source§

impl Eq 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, 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> NativeObject for T
where T: Any + Debug + Trace,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert the Rust type which implements NativeObject to a &dyn Any.
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Convert the Rust type which implements NativeObject to a &mut dyn Any.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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> DynCopy for T
where T: Copy,