diff --git a/Cargo.toml b/Cargo.toml index fa98be4787..ae40385a71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ gc = "0.3.2" gc_derive = "0.3.2" serde_json = "1.0" rand = "0.5.5" -time = "0.1" +chrono = "0.4" [lib] name = "boa" diff --git a/src/lib/js/console.rs b/src/lib/js/console.rs index f77fccad15..4621ee8b8f 100644 --- a/src/lib/js/console.rs +++ b/src/lib/js/console.rs @@ -2,14 +2,16 @@ use gc::Gc; use crate::js::function::NativeFunctionData; use crate::js::value::{from_value, to_value, ResultValue, Value, ValueData}; use std::iter::FromIterator; -use time::{now, strftime}; +use chrono::Local; + /// Print a javascript value to the standard output stream pub fn log(_: Value, _: Value, args: Vec) -> ResultValue { let args: Vec = FromIterator::from_iter( args.iter() .map(|x| from_value::(x.clone()).unwrap()), ); - println!("{}: {}", strftime("%X", &now()).unwrap(), args.join(" ")); + + println!("{}: {}", Local::now().format("%X").to_string(), args.join(" ")); Ok(Gc::new(ValueData::Undefined)) } /// Print a javascript value to the standard error stream @@ -18,7 +20,7 @@ pub fn error(_: Value, _: Value, args: Vec) -> ResultValue { args.iter() .map(|x| from_value::(x.clone()).unwrap()), ); - eprintln!("{}: {}", strftime("%X", &now()).unwrap(), args.join(" ")); + println!("{}: {}", Local::now().format("%X").to_string(), args.join(" ")); Ok(Gc::new(ValueData::Undefined)) } /// Create a new `console` object diff --git a/src/lib/lib.rs b/src/lib/lib.rs index f93c8b94d0..1c4a555f15 100644 --- a/src/lib/lib.rs +++ b/src/lib/lib.rs @@ -1,7 +1,7 @@ extern crate gc; extern crate rand; extern crate serde_json; -extern crate time; +extern crate chrono; #[macro_use] extern crate gc_derive;