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
impl Date
Sourcepub fn new() -> Self
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.
Sourcepub fn from_datetime(
year: i32,
month: i32,
day: i32,
hours: i32,
minutes: i32,
seconds: i32,
milliseconds: i32,
) -> Self
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
Sourcepub fn from_iso8601(date_string: &str) -> Self
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).
Sourcepub fn from_time(now: f64) -> Self
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).
Sourcepub fn utc(
year: i32,
month: i32,
day: i32,
hours: i32,
minutes: i32,
seconds: i32,
milliseconds: i32,
) -> f64
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.
Sourcepub fn parse(date_string: &str) -> f64
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).
Sourcepub fn now() -> f64
pub fn now() -> f64
The Date.now() method returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
Sourcepub fn get_date(&self) -> i32
pub fn get_date(&self) -> i32
The getDate() method returns the day of the month for the specified date according to local time.
Sourcepub fn get_day(&self) -> i32
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().
Sourcepub fn get_full_year(&self) -> i32
pub fn get_full_year(&self) -> i32
The getFullYear() method returns the year of the specified date according to local time.
Sourcepub fn get_hours(&self) -> i32
pub fn get_hours(&self) -> i32
The getHours() method returns the hour for the specified date, according to local time.
Sourcepub fn get_milliseconds(&self) -> i32
pub fn get_milliseconds(&self) -> i32
The getMilliseconds() method returns the milliseconds in the specified date according to local time.
Sourcepub fn get_minutes(&self) -> i32
pub fn get_minutes(&self) -> i32
The getMinutes() method returns the minutes in the specified date according to local time.
Sourcepub fn get_month(&self) -> i32
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).
Sourcepub fn get_seconds(&self) -> i32
pub fn get_seconds(&self) -> i32
The getSeconds() method returns the seconds in the specified date according to local time.
Sourcepub fn get_time(&self) -> f64
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.
Sourcepub fn get_timezone_offset(&self) -> i32
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.
Sourcepub fn get_utc_date(&self) -> i32
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.
Sourcepub fn get_utc_day(&self) -> i32
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.
Sourcepub fn get_utc_full_year(&self) -> i32
pub fn get_utc_full_year(&self) -> i32
The getUTCFullYear() method returns the year in the specified date according to universal time.
Sourcepub fn get_utc_hours(&self) -> i32
pub fn get_utc_hours(&self) -> i32
The getUTCHours() method returns the hours in the specified date according to universal time.
Sourcepub fn get_utc_milliseconds(&self) -> i32
pub fn get_utc_milliseconds(&self) -> i32
The getUTCMilliseconds() method returns the milliseconds in the specified date according to universal time.
Sourcepub fn get_utc_minutes(&self) -> i32
pub fn get_utc_minutes(&self) -> i32
The getUTCMinutes() method returns the minutes in the specified date according to universal time.
Sourcepub fn get_utc_month(&self) -> i32
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).
Sourcepub fn get_utc_seconds(&self) -> i32
pub fn get_utc_seconds(&self) -> i32
The getUTCSeconds() method returns the seconds in the specified date according to universal time.
Sourcepub fn set_date(&self, date: i32)
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.
Sourcepub fn set_full_year(&self, full_year: i32)
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.
Sourcepub fn set_hours(&self, hours: i32)
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.
Sourcepub fn set_milliseconds(&self, milliseconds: i32)
pub fn set_milliseconds(&self, milliseconds: i32)
The setMilliseconds() method sets the milliseconds for a specified date according to local time.
Sourcepub fn set_minutes(&self, minutes: i32)
pub fn set_minutes(&self, minutes: i32)
The setMinutes() method sets the minutes for a specified date according to local time.
Sourcepub fn set_month(&self, month: i32)
pub fn set_month(&self, month: i32)
The setMonth() method sets the month for a specified date according to the currently set year.
Sourcepub fn set_seconds(&self, seconds: i32)
pub fn set_seconds(&self, seconds: i32)
The setSeconds() method sets the seconds for a specified date according to local time.
Sourcepub fn set_time(&self, time: f64)
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.
Sourcepub fn set_utc_date(&self, date: i32)
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.
Sourcepub fn set_utc_full_year(&self, full_year: i32)
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.
Sourcepub fn set_utc_hours(&self, hours: i32)
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.
Sourcepub fn set_utc_milliseconds(&self, milliseconds: i32)
pub fn set_utc_milliseconds(&self, milliseconds: i32)
The setUTCMilliseconds() method sets the milliseconds for a specified date according to universal time.
Sourcepub fn set_utc_minutes(&self, minutes: i32)
pub fn set_utc_minutes(&self, minutes: i32)
The setUTCMinutes() method sets the minutes for a specified date according to universal time.
Sourcepub fn set_utc_month(&self, month: i32)
pub fn set_utc_month(&self, month: i32)
The setUTCMonth() method sets the month for a specified date according to universal time.
Sourcepub fn set_utc_seconds(&self, seconds: i32)
pub fn set_utc_seconds(&self, seconds: i32)
The setUTCSeconds() method sets the seconds for a specified date according to universal time.
Sourcepub fn to_date_string(&self) -> String
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.
Sourcepub fn to_iso_string(&self) -> String
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”.
Sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
The toJSON() method returns a string representation of the Date object.
Sourcepub fn to_string(&self) -> String
pub fn to_string(&self) -> String
The toString() method returns a string representing the specified Date object.
Sourcepub fn to_time_string(&self) -> String
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.
Sourcepub fn to_utc_string(&self) -> String
pub fn to_utc_string(&self) -> String
The toUTCString() method converts a date to a string, using the UTC time zone.
Trait Implementations§
Source§impl InstanceOf for Date
impl InstanceOf for Date
Source§impl ReferenceType for Date
impl ReferenceType for Date
Source§unsafe fn from_reference_unchecked(reference: Reference) -> Self
unsafe fn from_reference_unchecked(reference: Reference) -> Self
impl Eq for Date
impl JsSerialize for Date
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)