rust-timeago 0.0.1-alpha

Yet another implementation of timeago
Documentation
  • Coverage
  • 0%
    0 out of 17 items documented0 out of 9 items with examples
  • Size
  • Source code size: 22.76 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.39 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • srinivasreddy

README

This is an yet another implementation of timeago time display.This library is mostly inspired from the strings you see on stackoverflow.com

Design

I haven't considered the leap second into design and i have taken generally 30 days as month. So you can assume that i have sacrificed accuracy of months at the altar of usability. An year is considered as 365.25 days long.

TODO.

  1. Haven't implemented tests for strings such as "Nov 1970 at 17:20:08". I need to use Faketime library to mock the current system time.

Usage

use time_ago::{Config, TimeAgo, TimeType};
fn usage() {
    let config = Config { 
        is_years: false,
        is_weeks: false,
        is_months: false,
    };
    let a = TimeAgo::with_config(config, TimeType::SystemTime(SystemTime::now()));
    assert_eq!(a.convert(), "just now");
}

You can also see the tests file for more usage.

License

MIT or Apache

copyright

Srinivas Reddy Thatiparthy