Skip to content

Commit

Permalink
migrate from 'time' to 'chrono', fixes issue boa-dev#3
Browse files Browse the repository at this point in the history
  • Loading branch information
AFRUITPIE committed Mar 10, 2019
1 parent cd21a2f commit bd6feb6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions src/lib/js/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Value>) -> ResultValue {
let args: Vec<String> = FromIterator::from_iter(
args.iter()
.map(|x| from_value::<String>(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
Expand All @@ -18,7 +20,7 @@ pub fn error(_: Value, _: Value, args: Vec<Value>) -> ResultValue {
args.iter()
.map(|x| from_value::<String>(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
Expand Down
2 changes: 1 addition & 1 deletion src/lib/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit bd6feb6

Please sign in to comment.