Questions tagged [chronic]

Chronic is a natural language date/time parser written in pure Ruby.

Chronic is a natural language date/time parser written in pure Ruby.

It can parse a wide range of date and time formats including simple ones such as "today", "tomorrow", more complex ones such as "5 months before now", "3rd thursday this september" as well as specific dates and times such as "may 27th" and "January 5 at 7pm".

See chronic.rubyforge.org for more details.

32 questions
28
votes
1 answer

Can using Chronic impair your sense of time?

Haha.. I'm using Chronic to parse the time users add in the Calendar. Where the code works and implements the right time, the end result is that, IF a user adds a time, then it has no date, and because it has no date, it will not show in results.…
Trip
  • 26,756
  • 46
  • 158
  • 277
7
votes
5 answers

Get the last Sunday of the Month

I'm using Chronic to get the last Sunday of the month of any given year. It will gladly give me the n‌th Sunday, but not the last. This works, but is not what I need: Chronic.parse('4th sunday in march', :now => Time.local(2015,1,1)) This is…
iconoclast
  • 21,213
  • 15
  • 102
  • 138
5
votes
1 answer

Problems installing rdoc, irb, bluecloth, chronic on fedora 12

What do these errors mean? [root@localhost config]# gem install bluecloth Building native extensions. This could take a while... ERROR: Error installing bluecloth: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb can't…
Vineeth Pradhan
  • 8,201
  • 7
  • 33
  • 34
4
votes
3 answers

Chronic (Ruby NLP date/time parser) for python?

Does anyone know of a library like chronic but for python? Thanks!
bob
4
votes
1 answer

NLP Date Parsing

I've been experimenting with a number of NLP text parsers, but have found that most fail at even some of the simplest tasks that occur in actual texts (aren't preprocessed to show how "great" the systems are. An example is the following: From…
user2694306
  • 3,832
  • 10
  • 47
  • 95
4
votes
2 answers

Rails chronic gem not validating as expected

I'm trying to enter the date '03/20/1985' into a text field called "birthday" and have it inserted into a database field with the column type "date". When i enter 10/20/1985, i get the error "Birthday is invalid", but when i enter 20/10/1985, it…
Catfish
  • 18,876
  • 54
  • 209
  • 353
3
votes
2 answers

does chronic have any options of date format it parses? (ruby)

I need to tell chronic that the format of date is day-month-year is that possible? The data I pass to chronic could also be words today/yesterday/2 days ago. Currently chronic gives me 2 Dec 2010 instead of 12 Feb 2010 from 12-02-2010 The only…
Radek
  • 13,813
  • 52
  • 161
  • 255
2
votes
1 answer

Is there a RubyGem for parsing store hours?

Are there any ruby gems to parse and standardize store hours? I've seen Chronic, but I don't think it'll work for this specific use case. For example, how would you parse Mon-Sun 11am-10pm or Hours today: 5:30 AM – 10:00 PM? Do you have to create…
paniwani
  • 659
  • 3
  • 9
  • 18
2
votes
2 answers

Chronic parsing of month/day

I am using Chronic to parse dates and it is parsing the string '8/15' as August 16, 2015. Any ideas on how I could get Chronic to recognize 8/15 as August 15, current year? Here is the test code: Chronic.parse('8/15') #=> 'Sun Aug 16 12:00:00 -0400…
Jamie Wright
  • 1,160
  • 10
  • 23
2
votes
1 answer

Chronic not selecting correct 1st monday of the month

def monday? require 'chronic' today = Date.today 1st_monday = Chronic.parse('1st monday of this month', now: today.beginning_of_month).to_date 3rd_monday = Chronic.parse('3th monday of this month', now: today.beginning_of_month).to_date …
user12763413
  • 1,177
  • 3
  • 18
  • 53
2
votes
3 answers

How to use Chronic to parse dates in a datetime text_field

I'm trying to get a text field that my users can enter in something that is parsable by the Chronic gem. Here is my model file: require 'chronic' class Event < ActiveRecord::Base belongs_to :user validates_presence_of :e_time …
Reti
  • 609
  • 4
  • 10
  • 21
2
votes
2 answers

Rails: Custom validations using ActiveModel

I am currently trying to make custom validations work with an input of dates, but, unfortunately, it doesn't seem to work. There are two pages inside the application, Index page and Search page. Inside the index page there is a text field that takes…
Tim
  • 1,326
  • 1
  • 15
  • 27
2
votes
1 answer

Why is Chronic incorrectly parsing for four letter months?

In Chronic 0.9.1, when parsing Febr 2013 I'm getting a result June 2013. Feb 2013 is parsed fine but Febr 2013 is not. I think the issue is when the month abvreviation has four letters. I need to: Parse Febr 2013 to February 2013, or Invalidate…
M.Octavio
  • 1,780
  • 2
  • 25
  • 39
1
vote
1 answer

Rubygems Chronic cannot parse "2010-09-12 3:12pm" but can parse "2010-09-12 3pm" or "last monday 3:12pm"?

It seems strange that "2010--9-12 3:12pm" is a weak spot of Chronic Rubygem? Is there a way to make it work? (or another gem that can do it?) I also hope to find a parser that can handle 2010-09-12 3:12pm UTC or other timezones such as PDT, PST,…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
1
vote
1 answer

How do set ruby Gem Chronic's default timezone to Specific Timezone without rails

Question By default, the Chronic gem uses the system timezone as the default timezone. They mention here (https://github.com/mojombo/chronic#time-zones), that I can use ActiveSupports Time.zone to change this. But i'm not using Rails, i'm using…
Mark Evans
  • 810
  • 10
  • 18
1
2 3