Git Product home page Git Product logo

two-timer's Introduction

two-timer

Rust library for parsing English time expressions into start and end timestamps

This takes English expressions and returns a time range which ideally matches the expression. You might use this for registering the temporal extent of an event, say, or finding lines in a log file.

Some expressions it can handle:

  • from now to eternity
  • today
  • tomorrow
  • last month
  • this year
  • 5/6/69
  • June 6, 2010
  • forever
  • 3:00 AM
  • 3AM
  • June '05
  • Monday through next Thursday
  • from mon at 15:00:05 to now
  • 1960-05-06
  • 5000BCE
  • next weekend
  • 2000
  • the nineteenth of March 1810
  • the 5th of November
  • the ides of March
  • the first
  • two seconds before 12:00 PM
  • 1 week after May first
  • 15 minutes around 12:13:43 PM
  • noon on May 6, 1969
  • midnight on May 6, 1969
  • Friday the 13th
  • 2 weeks ago
  • ten seconds from now
  • 5 minutes before and after midnight
  • 1969-05-06 12:03:05
  • since the start of the year
  • since yesterday

The complete API is available at https://docs.rs/two_timer/.

two-timer's People

Contributors

dfhoughton avatar paradyx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

two-timer's Issues

Numeral dates with december fail to parse

It appears as if, dates with numeral Decembers are not parsable by this library. (e.g. 2023-12-25, 12/24/23, etc.)
After a short investigation, I found a typo in the GRAMMAR.

This rule[sic] is not including the 12th month in the range.

        n_month => [
                (1..12)
                    .into_iter()
                    .flat_map(|i| vec![format!("{:02}", i), format!("{}", i)])
                    .collect::<Vec<_>>()
            ]

Extremely high memory usage

On my system, the first call to parse allocates 1.7 GiB of memory (and caused an OOM in my original use case). Tracing the allocations back, it appears that pidgin::matching::Matcher::parse is causing multiple ~500 MiB allocations in regex_automata.

Is this expected behavior? (If so, it should be documented, since it makes this library impossible to use in many applications.)

missing time patterns

  • <period> before/after/around <time>
  • ordinal expressions for days of the month
  • <n> <periods> ago/from now
  • <year>
  • "the fifteenth", "the 1st of March", "5-6"
  • noon, midnight
  • Friday the 13th

Config value for default in the future

Hi!

I've used this library for a Matrix bot to set reminders. We currently type "18:00 today", because "18:00" is in the past (it assumes yesterday). Is it possible to somehow add a field to Config, to configure two_timer to assume times lie in the future, instead of in the past?

Thanks!

Ruben

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.