mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-31 17:31:06 +00:00
Add date to utc string
This commit is contained in:
parent
cd189d53c4
commit
033ba3f3a7
@ -377,6 +377,13 @@ extern {
|
|||||||
extern {
|
extern {
|
||||||
pub type Date;
|
pub type Date;
|
||||||
|
|
||||||
|
/// The toUTCString() method converts a date to a string,
|
||||||
|
/// using the UTC time zone.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString
|
||||||
|
#[wasm_bindgen(method, js_name = toUTCString)]
|
||||||
|
pub fn to_utc_string(this: &Date) -> JsString;
|
||||||
|
|
||||||
/// The valueOf() method returns the primitive value of
|
/// The valueOf() method returns the primitive value of
|
||||||
/// a Date object.
|
/// a Date object.
|
||||||
///
|
///
|
||||||
|
@ -2,6 +2,33 @@
|
|||||||
|
|
||||||
use super::project;
|
use super::project;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn to_utc_string() {
|
||||||
|
project()
|
||||||
|
.file("src/lib.rs", r#"
|
||||||
|
#![feature(proc_macro, wasm_custom_section)]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
use wasm_bindgen::js::{Date, JsString};
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn to_utc_string(this: &Date) -> JsString {
|
||||||
|
this.to_utc_string()
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.file("test.ts", r#"
|
||||||
|
import * as assert from "assert";
|
||||||
|
import * as wasm from "./out";
|
||||||
|
|
||||||
|
export function test() {
|
||||||
|
let date = new Date('14 Jun 2017 00:00:00 PDT');
|
||||||
|
assert.equal(wasm.to_utc_string(date), "Wed, 14 Jun 2017 07:00:00 GMT");
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.test()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn value_of() {
|
fn value_of() {
|
||||||
project()
|
project()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user