No commit activity in last 3 years
No release in over 3 years
Todo time patterns is a small library that helps you to parse different time patterns in strings like: - meet bob at 4pm - meeting at 13:34 - watch Adventure Times at 3:34pm - Go shopping at 2pm for 2h - Pay your tech. debt at 2pm for 35mins to Mafia - Sleep well from 1am to 8:00 etc.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Todo time patterns

Small library that helps you parse a string and get information about time patterns in it.

It parses next patterns:

  • Meeting at 11:00
  • Meeting at 11am
  • Party at 11:45pm
  • Meet Bob at 11:00 for 30m to discuss the project
  • Meet James at 11:00 for 1h
  • Watch Adventure Time from 11:00 to 11pm to stay CRAZY

it supports modifiers for minutes and hours like:

  • m, min, mins, minutes
  • h, hour, hours

it recognizes time patterns ({time}) as:

  • 11:00
  • 11am/pm
  • 3:45pm

and uses those patterns to recognize intervals like:

  • at {time} for {interval}
  • from {time} to {time}

where {interval} can be "30 minutes" or "1 hour" or "1 hour 34min.

How to use

require "todo_time_patterns"

input = "meet Bob at 4pm for 2 hours 30min"
p TodoTimePatterns.parse input

#prints {:hours=>16, :minutes=>0, :interval=>150, :result_string=>"meet Bob"} on screen

#-------

input = "meet Bob at 16:34"
p TodoTimePatterns.parse input

#prints {:hours=>16, :minutes=>34, :interval=>0, :result_string=>"meet Bob"}

Setup

gem install 'todo_time_patterns'