pub struct Date(_);
Implementations
sourceimpl Date
impl Date
sourcepub fn time_clip(time: f64) -> Option<f64>
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:
sourcepub fn to_local(self) -> Option<DateTime<Local>>
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
.
sourcepub fn to_utc(self) -> Option<DateTime<Utc>>
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
.
sourcepub 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>
)
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.
sourcepub fn get_date(&self) -> f64
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:
sourcepub fn get_day(&self) -> f64
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:
sourcepub fn get_full_year(&self) -> f64
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:
sourcepub fn get_hours(&self) -> f64
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:
sourcepub fn get_milliseconds(&self) -> f64
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:
sourcepub fn get_minutes(&self) -> f64
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:
sourcepub fn get_month(&self) -> f64
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:
sourcepub fn get_seconds(&self) -> f64
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:
sourcepub fn get_year(&self) -> f64
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:
sourcepub fn get_time(&self) -> f64
pub fn get_time(&self) -> f64
Date.prototype.getTime()
The getTime()
method returns the number of milliseconds since the Unix Epoch.
More information:
sourcepub fn get_timezone_offset(
this: &JsValue,
_: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn get_utc_date(&self) -> f64
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:
sourcepub fn get_utc_day(&self) -> f64
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:
sourcepub fn get_utc_full_year(&self) -> f64
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:
sourcepub fn get_utc_hours(&self) -> f64
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:
sourcepub fn get_utc_milliseconds(&self) -> f64
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:
sourcepub fn get_utc_minutes(&self) -> f64
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:
sourcepub fn get_utc_month(&self) -> f64
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:
sourcepub fn get_utc_seconds(&self) -> f64
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:
sourcepub fn set_date(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_full_year(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_hours(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_milliseconds(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_minutes(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_month(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_seconds(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_year(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_time(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_utc_date(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_utc_full_year(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_utc_hours(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_utc_milliseconds(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_utc_minutes(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_utc_month(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn set_utc_seconds(
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn to_date_string(
this: &JsValue,
_: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn to_gmt_string(self) -> String
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:
sourcepub fn to_iso_string(
this: &JsValue,
_: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn to_json(
this: &JsValue,
_: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn to_string(
this: &JsValue,
_: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn to_time_string(
this: &JsValue,
_: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
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:
sourcepub fn to_utc_string(self) -> String
pub fn to_utc_string(self) -> String
Date.prototype.toUTCString()
The toUTCString()
method returns a string representing the specified Date object.
More information:
Trait Implementations
sourceimpl Ord for Date
impl Ord for Date
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl PartialOrd<Date> for Date
impl PartialOrd<Date> for Date
sourcefn partial_cmp(&self, other: &Date) -> Option<Ordering>
fn partial_cmp(&self, other: &Date) -> Option<Ordering>
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 Trace for Date
impl Trace for Date
sourcefn finalize_glue(&self)
fn finalize_glue(&self)
impl Copy for Date
impl Eq for Date
impl StructuralEq for Date
impl StructuralPartialEq for Date
Auto Trait Implementations
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnwindSafe for Date
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.