daxpedda / web-time Goto Github PK
View Code? Open in Web Editor NEWDrop-in replacement for std::time for Wasm in browsers
License: Apache License 2.0
Drop-in replacement for std::time for Wasm in browsers
License: Apache License 2.0
I'm interested in using this API in async-io
, but to do that this crate would need to have a v1.0 release.
I don't imagine that there will be any future breaking changes, as it tries to align itself with std::time
's API which won't have breaking changes.
I ran into a case where I needed to cast an instance of web_time::SystemTime
back to a std::time::SystemTime
since another library's struct explicitly required that type.
I came up with this function as a bandaid:
fn to_std_systemtime(time: web_time::SystemTime) -> std::time::SystemTime {
let ts_millis = time.duration_since(SystemTime::UNIX_EPOCH).unwrap().as_millis();
let ts_secs = ts_millis / 1000;
let ts_ns = (ts_millis % 1000) * 1_000_000 ;
let dt = DateTime::<Utc>::from_timestamp(ts_secs as i64, ts_ns as u32).unwrap();
return std::time::SystemTime::from(dt);
}
Is there a nicer way to do this? Would it make sense to include such a function in the lib?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.