vi / timeago Goto Github PK
View Code? Open in Web Editor NEWIn Rust, format Duration into a string like "1 hour ago" or "01hou".
Home Page: https://docs.rs/timeago/
License: Apache License 2.0
In Rust, format Duration into a string like "1 hour ago" or "01hou".
Home Page: https://docs.rs/timeago/
License: Apache License 2.0
Humans can't really comprehend time at the microseconds level. We need a format to put less than 1 second to 'just now'.
from: src/languages/french.rs
assert_eq!(f.convert(Duration::from_secs(60)), "il y a 1 minute");
But running the command:
$ cargo run fr
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
Running `(..)/timeago/target/debug/timeago fr`
60
1 minute il y a
Currently the format only displays the highest unit of time and chops off the rest. It would be great for it to include hours, minutes, seconds etc if you want and be customizable.
Can you make the ago part of the string optional? It's useful in more contexts that way
Hi! I'm working on packaging this crate for Fedora Linux since it is a new dependency of eza (a maintained exa fork). During technical review, we noticed that this crate's metadata states that the license is "MIT/Apache-2.0", but the license text only contains the MIT license.
Please also include a copy of the Apache-2.0 license text (the idiomatic way to handle this in Rust crates seems to be to have both LICENSE-MIT
and LICENSE-APACHE
files). Both the MIT and the Apache-2.0 license require redistributed sources to contain a copy of the license text, so the missing license text is currently preventing us from packaging eza.
I am trying to run the example code for using convert_chrono in my own project, and I am being told by rustc that the method cannot be found on the Formatter type. I've checked all of my imports and such and I can't tell why I am still getting this error. I am using timeago 0.1 on rustc 1.25 (stable-x86_64-apple-darwin). I can work around it by converting my DateTimes to a Duration first and using the regular convert function but would appreciate it if this one worked too as it would simplify my code. Any help figuring out why this isn't working is appreciated, thank you for creating such a useful library.
edit: here's the code in my project
let mut f = timeago::Formatter::new();
f.num_items(2);
let from = chrono::DateTime::parse_from_rfc3339("2013-12-19T15:00:00+03:00").unwrap();
let to = chrono::DateTime::parse_from_rfc3339("2013-12-23T17:00:00+03:00").unwrap();
assert_eq!(f.convert_chrono(from, to), "4 days 2 hours ago");
the method convert_chrono is not found on the type that F is (Formatter)
It would be nice to have the equivalent of .ago("ago")
but for future times like .in("in")
so when you have a time in the future it says in 8 hours
and ago()
and in()
are mutually exclusive.
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.