@ -40,7 +40,7 @@ pub struct JsDate {
impl JsDate {
/// Create a new `Date` object with universal time.
#[ inline ]
pub fn new ( context : & mut Context ) -> Self {
pub fn new ( context : & mut Context < ' _ > ) -> Self {
let prototype = context . intrinsics ( ) . constructors ( ) . date ( ) . prototype ( ) ;
let inner = JsObject ::from_proto_and_data ( prototype , ObjectData ::date ( Date ::default ( ) ) ) ;
@ -51,7 +51,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.now()`
#[ inline ]
pub fn now ( context : & mut Context ) -> JsResult < JsValue > {
pub fn now ( context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::now ( & JsValue ::Null , & [ JsValue ::Null ] , context )
}
@ -63,7 +63,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.parse(value)`.
#[ inline ]
pub fn parse ( value : JsValue , context : & mut Context ) -> JsResult < JsValue > {
pub fn parse ( value : JsValue , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::parse ( & JsValue ::Null , & [ value ] , context )
}
@ -72,7 +72,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.UTC()`
#[ inline ]
pub fn utc ( values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn utc ( values : & [ JsValue ] , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::utc ( & JsValue ::Null , values , context )
}
@ -81,7 +81,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getDate()`.
#[ inline ]
pub fn get_date ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_date ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_date ::< true > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -90,7 +90,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getDay()`.
#[ inline ]
pub fn get_day ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_day ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_day ::< true > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -99,7 +99,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getFullYear()`.
#[ inline ]
pub fn get_full_year ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_full_year ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_full_year ::< true > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -107,7 +107,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getHours()`.
#[ inline ]
pub fn get_hours ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_hours ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_hours ::< true > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -116,7 +116,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getMilliseconds()`.
#[ inline ]
pub fn get_milliseconds ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_milliseconds ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_milliseconds ::< true > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -124,7 +124,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getMinutes()`.
#[ inline ]
pub fn get_minutes ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_minutes ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_minutes ::< true > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -132,7 +132,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getMonth()`.
#[ inline ]
pub fn get_month ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_month ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_month ::< true > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -140,7 +140,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getSeconds()`.
#[ inline ]
pub fn get_seconds ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_seconds ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_seconds ::< true > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -150,7 +150,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getTime()`.
#[ inline ]
pub fn get_time ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_time ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_time ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -158,7 +158,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getTimezoneOffset()`.
#[ inline ]
pub fn get_timezone_offset ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_timezone_offset ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_timezone_offset ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::Null ] , context )
}
@ -167,7 +167,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getUTCDate()`.
#[ inline ]
pub fn get_utc_date ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_utc_date ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_date ::< false > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -176,7 +176,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getUTCDay()`.
#[ inline ]
pub fn get_utc_day ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_utc_day ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_day ::< false > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -185,7 +185,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getUTCFullYear()`.
#[ inline ]
pub fn get_utc_full_year ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_utc_full_year ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_full_year ::< false > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -194,7 +194,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getUTCHours()`.
#[ inline ]
pub fn get_utc_hours ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_utc_hours ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_hours ::< false > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -203,7 +203,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getUTCMilliseconds()`.
#[ inline ]
pub fn get_utc_milliseconds ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_utc_milliseconds ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_milliseconds ::< false > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -212,7 +212,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getUTCMinutes()`.
#[ inline ]
pub fn get_utc_minutes ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_utc_minutes ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_minutes ::< false > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -221,7 +221,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getUTCMonth()`.
#[ inline ]
pub fn get_utc_month ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_utc_month ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_month ::< false > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -230,7 +230,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.getUTCSeconds()`.
#[ inline ]
pub fn get_utc_seconds ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn get_utc_seconds ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::get_seconds ::< false > ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::null ( ) ] , context )
}
@ -241,7 +241,7 @@ impl JsDate {
/// the UNIX epoch and the given date.
///
/// Same as JavaScript's `Date.prototype.setDate()`.
pub fn set_date < T > ( & self , value : T , context : & mut Context ) -> JsResult < JsValue >
pub fn set_date < T > ( & self , value : T , context : & mut Context < ' _ > ) -> JsResult < JsValue >
where
T : Into < JsValue > ,
{
@ -256,7 +256,11 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.setFullYear()`.
#[ inline ]
pub fn set_full_year ( & self , values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn set_full_year (
& self ,
values : & [ JsValue ] ,
context : & mut Context < ' _ > ,
) -> JsResult < JsValue > {
Date ::set_full_year ::< true > ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -267,7 +271,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.setHours()`.
#[ inline ]
pub fn set_hours ( & self , values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn set_hours ( & self , values : & [ JsValue ] , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::set_hours ::< true > ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -277,7 +281,7 @@ impl JsDate {
/// the UNIX epoch and updated date.
///
/// Same as JavaScript's `Date.prototype.setMilliseconds()`.
pub fn set_milliseconds < T > ( & self , value : T , context : & mut Context ) -> JsResult < JsValue >
pub fn set_milliseconds < T > ( & self , value : T , context : & mut Context < ' _ > ) -> JsResult < JsValue >
where
T : Into < JsValue > ,
{
@ -291,7 +295,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.setMinutes()`.
#[ inline ]
pub fn set_minutes ( & self , values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn set_minutes ( & self , values : & [ JsValue ] , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::set_minutes ::< true > ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -302,7 +306,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.setMonth()`.
#[ inline ]
pub fn set_month ( & self , values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn set_month ( & self , values : & [ JsValue ] , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::set_month ::< true > ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -313,7 +317,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.setSeconds()`.
#[ inline ]
pub fn set_seconds ( & self , values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn set_seconds ( & self , values : & [ JsValue ] , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::set_seconds ::< true > ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -325,7 +329,7 @@ impl JsDate {
/// the UNIX epoch and the updated date.
///
/// Same as JavaScript's `Date.prototype.setTime()`.
pub fn set_time < T > ( & self , value : T , context : & mut Context ) -> JsResult < JsValue >
pub fn set_time < T > ( & self , value : T , context : & mut Context < ' _ > ) -> JsResult < JsValue >
where
T : Into < JsValue > ,
{
@ -339,7 +343,7 @@ impl JsDate {
/// the UNIX epoch and the updated date.
///
/// Same as JavaScript's `Date.prototype.setUTCDate()`.
pub fn set_utc_date < T > ( & self , value : T , context : & mut Context ) -> JsResult < JsValue >
pub fn set_utc_date < T > ( & self , value : T , context : & mut Context < ' _ > ) -> JsResult < JsValue >
where
T : Into < JsValue > ,
{
@ -357,7 +361,7 @@ impl JsDate {
pub fn set_utc_full_year (
& self ,
values : & [ JsValue ] ,
context : & mut Context ,
context : & mut Context < ' _ > ,
) -> JsResult < JsValue > {
Date ::set_full_year ::< false > ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -369,7 +373,11 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.setUTCHours()`.
#[ inline ]
pub fn set_utc_hours ( & self , values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn set_utc_hours (
& self ,
values : & [ JsValue ] ,
context : & mut Context < ' _ > ,
) -> JsResult < JsValue > {
Date ::set_hours ::< false > ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -379,7 +387,7 @@ impl JsDate {
/// the UNIX epoch and the updated date.
///
/// Same as JavaScript's `Date.prototype.setUTCMilliseconds()`.
pub fn set_utc_milliseconds < T > ( & self , value : T , context : & mut Context ) -> JsResult < JsValue >
pub fn set_utc_milliseconds < T > ( & self , value : T , context : & mut Context < ' _ > ) -> JsResult < JsValue >
where
T : Into < JsValue > ,
{
@ -393,7 +401,11 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.setUTCMinutes()`.
#[ inline ]
pub fn set_utc_minutes ( & self , values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn set_utc_minutes (
& self ,
values : & [ JsValue ] ,
context : & mut Context < ' _ > ,
) -> JsResult < JsValue > {
Date ::set_minutes ::< false > ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -404,7 +416,11 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.setUTCMonth()`.
#[ inline ]
pub fn set_utc_month ( & self , values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn set_utc_month (
& self ,
values : & [ JsValue ] ,
context : & mut Context < ' _ > ,
) -> JsResult < JsValue > {
Date ::set_month ::< false > ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -415,7 +431,11 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.setUTCSeconds()`.
#[ inline ]
pub fn set_utc_seconds ( & self , values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn set_utc_seconds (
& self ,
values : & [ JsValue ] ,
context : & mut Context < ' _ > ,
) -> JsResult < JsValue > {
Date ::set_seconds ::< false > ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -423,7 +443,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.toDateString()`.
#[ inline ]
pub fn to_date_string ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn to_date_string ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::to_date_string ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::Null ] , context )
}
@ -434,7 +454,7 @@ impl JsDate {
/// Same as JavaScript's legacy `Date.prototype.toGMTString()`
#[ deprecated ]
#[ inline ]
pub fn to_gmt_string ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn to_gmt_string ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::to_gmt_string ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::Null ] , context )
}
@ -443,7 +463,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.toISOString()`.
#[ inline ]
pub fn to_iso_string ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn to_iso_string ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::to_iso_string ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::Null ] , context )
}
@ -451,7 +471,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.toJSON()`.
#[ inline ]
pub fn to_json ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn to_json ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::to_json ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::Null ] , context )
}
@ -464,7 +484,7 @@ impl JsDate {
pub fn to_local_date_string (
& self ,
values : & [ JsValue ] ,
context : & mut Context ,
context : & mut Context < ' _ > ,
) -> JsResult < JsValue > {
Date ::to_locale_date_string ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -474,7 +494,11 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.toLocaleDateString()`.
#[ inline ]
pub fn to_locale_string ( & self , values : & [ JsValue ] , context : & mut Context ) -> JsResult < JsValue > {
pub fn to_locale_string (
& self ,
values : & [ JsValue ] ,
context : & mut Context < ' _ > ,
) -> JsResult < JsValue > {
Date ::to_locale_string ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -485,7 +509,7 @@ impl JsDate {
pub fn to_locale_time_string (
& self ,
values : & [ JsValue ] ,
context : & mut Context ,
context : & mut Context < ' _ > ,
) -> JsResult < JsValue > {
Date ::to_locale_time_string ( & self . inner . clone ( ) . into ( ) , values , context )
}
@ -494,7 +518,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.toString()`.
#[ inline ]
pub fn to_string ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn to_string ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::to_string ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::Null ] , context )
}
@ -502,7 +526,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.toTimeString()`.
#[ inline ]
pub fn to_time_string ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn to_time_string ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::to_time_string ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::Null ] , context )
}
@ -510,7 +534,7 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.toUTCString()`.
#[ inline ]
pub fn to_utc_string ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn to_utc_string ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::to_utc_string ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::Null ] , context )
}
@ -518,12 +542,12 @@ impl JsDate {
///
/// Same as JavaScript's `Date.prototype.valueOf()`.
#[ inline ]
pub fn value_of ( & self , context : & mut Context ) -> JsResult < JsValue > {
pub fn value_of ( & self , context : & mut Context < ' _ > ) -> JsResult < JsValue > {
Date ::value_of ( & self . inner . clone ( ) . into ( ) , & [ JsValue ::Null ] , context )
}
/// Utility create a `Date` object from RFC3339 string
pub fn new_from_parse ( value : & JsValue , context : & mut Context ) -> JsResult < Self > {
pub fn new_from_parse ( value : & JsValue , context : & mut Context < ' _ > ) -> JsResult < Self > {
let prototype = context . intrinsics ( ) . constructors ( ) . date ( ) . prototype ( ) ;
let string = value
. to_string ( context ) ?