chronic 0.1.5 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +5 -0
  3. data/.yardopts +3 -0
  4. data/HISTORY.md +180 -0
  5. data/LICENSE +21 -0
  6. data/README.md +176 -0
  7. data/Rakefile +39 -32
  8. data/chronic.gemspec +17 -0
  9. data/lib/chronic/chronic.rb +294 -208
  10. data/lib/chronic/grabber.rb +22 -17
  11. data/lib/chronic/handler.rb +90 -0
  12. data/lib/chronic/handlers.rb +365 -278
  13. data/lib/chronic/mini_date.rb +38 -0
  14. data/lib/chronic/numerizer.rb +121 -0
  15. data/lib/chronic/ordinal.rb +23 -19
  16. data/lib/chronic/pointer.rb +20 -17
  17. data/lib/chronic/repeater.rb +126 -105
  18. data/lib/chronic/repeaters/repeater_day.rb +49 -43
  19. data/lib/chronic/repeaters/repeater_day_name.rb +48 -42
  20. data/lib/chronic/repeaters/repeater_day_portion.rb +81 -80
  21. data/lib/chronic/repeaters/repeater_fortnight.rb +59 -53
  22. data/lib/chronic/repeaters/repeater_hour.rb +49 -43
  23. data/lib/chronic/repeaters/repeater_minute.rb +55 -39
  24. data/lib/chronic/repeaters/repeater_month.rb +77 -55
  25. data/lib/chronic/repeaters/repeater_month_name.rb +83 -82
  26. data/lib/chronic/repeaters/repeater_season.rb +107 -21
  27. data/lib/chronic/repeaters/repeater_season_name.rb +41 -22
  28. data/lib/chronic/repeaters/repeater_second.rb +39 -33
  29. data/lib/chronic/repeaters/repeater_time.rb +117 -103
  30. data/lib/chronic/repeaters/repeater_week.rb +63 -57
  31. data/lib/chronic/repeaters/repeater_weekday.rb +85 -0
  32. data/lib/chronic/repeaters/repeater_weekend.rb +64 -9
  33. data/lib/chronic/repeaters/repeater_year.rb +70 -51
  34. data/lib/chronic/scalar.rb +64 -29
  35. data/lib/chronic/season.rb +37 -0
  36. data/lib/chronic/separator.rb +50 -38
  37. data/lib/chronic/span.rb +31 -0
  38. data/lib/chronic/tag.rb +42 -0
  39. data/lib/chronic/time_zone.rb +30 -0
  40. data/lib/chronic/token.rb +45 -0
  41. data/lib/chronic.rb +86 -22
  42. data/test/helper.rb +6 -0
  43. data/test/test_Chronic.rb +118 -20
  44. data/test/test_DaylightSavings.rb +118 -0
  45. data/test/test_Handler.rb +36 -42
  46. data/test/test_MiniDate.rb +32 -0
  47. data/test/test_Numerizer.rb +72 -0
  48. data/test/test_RepeaterDayName.rb +15 -16
  49. data/test/test_RepeaterFortnight.rb +16 -17
  50. data/test/test_RepeaterHour.rb +22 -19
  51. data/test/test_RepeaterMinute.rb +34 -0
  52. data/test/test_RepeaterMonth.rb +20 -17
  53. data/test/test_RepeaterMonthName.rb +17 -18
  54. data/test/test_RepeaterSeason.rb +40 -0
  55. data/test/test_RepeaterTime.rb +20 -22
  56. data/test/test_RepeaterWeek.rb +16 -17
  57. data/test/test_RepeaterWeekday.rb +55 -0
  58. data/test/test_RepeaterWeekend.rb +74 -0
  59. data/test/test_RepeaterYear.rb +24 -18
  60. data/test/test_Span.rb +5 -6
  61. data/test/test_Token.rb +5 -6
  62. data/test/test_parsing.rb +743 -338
  63. metadata +81 -54
  64. data/History.txt +0 -29
  65. data/Manifest.txt +0 -43
  66. data/README.txt +0 -149
  67. data/test/parse_numbers.rb +0 -50
  68. data/test/suite.rb +0 -9
@@ -1,74 +1,109 @@
1
1
  module Chronic
2
+ class Scalar < Tag
3
+ DAY_PORTIONS = %w( am pm morning afternoon evening night )
2
4
 
3
- class Scalar < Tag #:nodoc:
4
- def self.scan(tokens)
5
- # for each token
5
+ # Scan an Array of {Token}s and apply any necessary Scalar tags to
6
+ # each token
7
+ #
8
+ # @param [Array<Token>] tokens Array of tokens to scan
9
+ # @param [Hash] options Options specified in {Chronic.parse}
10
+ # @return [Array] list of tokens
11
+ def self.scan(tokens, options)
6
12
  tokens.each_index do |i|
7
- if t = self.scan_for_scalars(tokens[i], tokens[i + 1]) then tokens[i].tag(t) end
8
- if t = self.scan_for_days(tokens[i], tokens[i + 1]) then tokens[i].tag(t) end
9
- if t = self.scan_for_months(tokens[i], tokens[i + 1]) then tokens[i].tag(t) end
10
- if t = self.scan_for_years(tokens[i], tokens[i + 1]) then tokens[i].tag(t) end
13
+ if t = scan_for_scalars(tokens[i], tokens[i + 1]) then tokens[i].tag(t) end
14
+ if t = scan_for_days(tokens[i], tokens[i + 1]) then tokens[i].tag(t) end
15
+ if t = scan_for_months(tokens[i], tokens[i + 1]) then tokens[i].tag(t) end
16
+ if t = scan_for_years(tokens[i], tokens[i + 1], options) then tokens[i].tag(t) end
11
17
  end
12
- tokens
13
18
  end
14
-
19
+
20
+ # @param [Token] token
21
+ # @param [Token] post_token
22
+ # @return [Scalar, nil]
15
23
  def self.scan_for_scalars(token, post_token)
16
24
  if token.word =~ /^\d*$/
17
- unless post_token && %w{am pm morning afternoon evening night}.include?(post_token)
25
+ unless post_token && DAY_PORTIONS.include?(post_token.word)
18
26
  return Scalar.new(token.word.to_i)
19
27
  end
20
28
  end
21
- return nil
22
29
  end
23
-
30
+
31
+ # @param [Token] token
32
+ # @param [Token] post_token
33
+ # @return [ScalarDay, nil]
24
34
  def self.scan_for_days(token, post_token)
25
35
  if token.word =~ /^\d\d?$/
26
- unless token.word.to_i > 31 || (post_token && %w{am pm morning afternoon evening night}.include?(post_token))
27
- return ScalarDay.new(token.word.to_i)
36
+ toi = token.word.to_i
37
+ unless toi > 31 || toi < 1 || (post_token && DAY_PORTIONS.include?(post_token.word))
38
+ return ScalarDay.new(toi)
28
39
  end
29
40
  end
30
- return nil
31
41
  end
32
-
42
+
43
+ # @param [Token] token
44
+ # @param [Token] post_token
45
+ # @return [ScalarMonth, nil]
33
46
  def self.scan_for_months(token, post_token)
34
47
  if token.word =~ /^\d\d?$/
35
- unless token.word.to_i > 12 || (post_token && %w{am pm morning afternoon evening night}.include?(post_token))
36
- return ScalarMonth.new(token.word.to_i)
48
+ toi = token.word.to_i
49
+ unless toi > 12 || toi < 1 || (post_token && DAY_PORTIONS.include?(post_token.word))
50
+ return ScalarMonth.new(toi)
37
51
  end
38
52
  end
39
- return nil
40
53
  end
41
-
42
- def self.scan_for_years(token, post_token)
54
+
55
+ # @param [Token] token
56
+ # @param [Token] post_token
57
+ # @param [Hash] options Options specified in {Chronic.parse}
58
+ # @return [ScalarYear, nil]
59
+ def self.scan_for_years(token, post_token, options)
43
60
  if token.word =~ /^([1-9]\d)?\d\d?$/
44
- unless post_token && %w{am pm morning afternoon evening night}.include?(post_token)
45
- return ScalarYear.new(token.word.to_i)
61
+ unless post_token && DAY_PORTIONS.include?(post_token.word)
62
+ year = make_year(token.word.to_i, options[:ambiguous_year_future_bias])
63
+ return ScalarYear.new(year.to_i)
46
64
  end
47
65
  end
48
- return nil
49
66
  end
50
-
67
+
68
+ # Build a year from a 2 digit suffix
69
+ #
70
+ # @example
71
+ # make_year(96, 50) #=> 1996
72
+ # make_year(79, 20) #=> 2079
73
+ # make_year(00, 50) #=> 2000
74
+ #
75
+ # @param [Integer] year The two digit year to build from
76
+ # @param [Integer] bias The amount of future years to bias
77
+ # @return [Integer] The 4 digit year
78
+ def self.make_year(year, bias)
79
+ return year if year.to_s.size > 2
80
+ start_year = Chronic.time_class.now.year - bias
81
+ century = (start_year / 100) * 100
82
+ full_year = century + year
83
+ full_year += 100 if full_year < start_year
84
+ full_year
85
+ end
86
+
51
87
  def to_s
52
88
  'scalar'
53
89
  end
54
90
  end
55
-
91
+
56
92
  class ScalarDay < Scalar #:nodoc:
57
93
  def to_s
58
94
  super << '-day-' << @type.to_s
59
95
  end
60
96
  end
61
-
97
+
62
98
  class ScalarMonth < Scalar #:nodoc:
63
99
  def to_s
64
100
  super << '-month-' << @type.to_s
65
101
  end
66
102
  end
67
-
103
+
68
104
  class ScalarYear < Scalar #:nodoc:
69
105
  def to_s
70
106
  super << '-year-' << @type.to_s
71
107
  end
72
108
  end
73
-
74
109
  end
@@ -0,0 +1,37 @@
1
+ module Chronic
2
+ class Season
3
+ # @return [MiniDate]
4
+ attr_reader :start
5
+
6
+ # @return [MiniDate]
7
+ attr_reader :end
8
+
9
+ # @param [MiniDate] start_date
10
+ # @param [MiniDate] end_date
11
+ def initialize(start_date, end_date)
12
+ @start = start_date
13
+ @end = end_date
14
+ end
15
+
16
+ # @param [Symbol] season The season name
17
+ # @param [Integer] pointer The direction (-1 for past, 1 for future)
18
+ # @return [Symbol] The new season name
19
+ def self.find_next_season(season, pointer)
20
+ lookup = [:spring, :summer, :autumn, :winter]
21
+ next_season_num = (lookup.index(season) + 1 * pointer) % 4
22
+ lookup[next_season_num]
23
+ end
24
+
25
+ # @param [Symbol] season The season name
26
+ # @return [Symbol] The new season name
27
+ def self.season_after(season)
28
+ find_next_season(season, +1)
29
+ end
30
+
31
+ # @param [Symbol] season The season name
32
+ # @return [Symbol] The new season name
33
+ def self.season_before(season)
34
+ find_next_season(season, -1)
35
+ end
36
+ end
37
+ end
@@ -1,76 +1,88 @@
1
1
  module Chronic
2
+ class Separator < Tag
2
3
 
3
- class Separator < Tag #:nodoc:
4
- def self.scan(tokens)
5
- tokens.each_index do |i|
6
- if t = self.scan_for_commas(tokens[i]) then tokens[i].tag(t); next end
7
- if t = self.scan_for_slash_or_dash(tokens[i]) then tokens[i].tag(t); next end
8
- if t = self.scan_for_at(tokens[i]) then tokens[i].tag(t); next end
9
- if t = self.scan_for_in(tokens[i]) then tokens[i].tag(t); next end
4
+ # Scan an Array of {Token}s and apply any necessary Separator tags to
5
+ # each token
6
+ #
7
+ # @param [Array<Token>] tokens Array of tokens to scan
8
+ # @param [Hash] options Options specified in {Chronic.parse}
9
+ # @return [Array] list of tokens
10
+ def self.scan(tokens, options)
11
+ tokens.each do |token|
12
+ if t = scan_for_commas(token) then token.tag(t); next end
13
+ if t = scan_for_slash_or_dash(token) then token.tag(t); next end
14
+ if t = scan_for_at(token) then token.tag(t); next end
15
+ if t = scan_for_in(token) then token.tag(t); next end
16
+ if t = scan_for_on(token) then token.tag(t); next end
10
17
  end
11
- tokens
12
18
  end
13
-
19
+
20
+ # @param [Token] token
21
+ # @return [SeparatorComma, nil]
14
22
  def self.scan_for_commas(token)
15
- scanner = {/^,$/ => :comma}
16
- scanner.keys.each do |scanner_item|
17
- return SeparatorComma.new(scanner[scanner_item]) if scanner_item =~ token.word
18
- end
19
- return nil
23
+ scan_for token, SeparatorComma, { /^,$/ => :comma }
20
24
  end
21
-
25
+
26
+ # @param [Token] token
27
+ # @return [SeparatorSlashOrDash, nil]
22
28
  def self.scan_for_slash_or_dash(token)
23
- scanner = {/^-$/ => :dash,
24
- /^\/$/ => :slash}
25
- scanner.keys.each do |scanner_item|
26
- return SeparatorSlashOrDash.new(scanner[scanner_item]) if scanner_item =~ token.word
27
- end
28
- return nil
29
+ scan_for token, SeparatorSlashOrDash,
30
+ {
31
+ /^-$/ => :dash,
32
+ /^\/$/ => :slash
33
+ }
29
34
  end
30
-
35
+
36
+ # @param [Token] token
37
+ # @return [SeparatorAt, nil]
31
38
  def self.scan_for_at(token)
32
- scanner = {/^(at|@)$/ => :at}
33
- scanner.keys.each do |scanner_item|
34
- return SeparatorAt.new(scanner[scanner_item]) if scanner_item =~ token.word
35
- end
36
- return nil
39
+ scan_for token, SeparatorAt, { /^(at|@)$/ => :at }
37
40
  end
38
-
41
+
42
+ # @param [Token] token
43
+ # @return [SeparatorIn, nil]
39
44
  def self.scan_for_in(token)
40
- scanner = {/^in$/ => :in}
41
- scanner.keys.each do |scanner_item|
42
- return SeparatorIn.new(scanner[scanner_item]) if scanner_item =~ token.word
43
- end
44
- return nil
45
+ scan_for token, SeparatorIn, { /^in$/ => :in }
46
+ end
47
+
48
+ # @param [Token] token
49
+ # @return [SeparatorOn, nil]
50
+ def self.scan_for_on(token)
51
+ scan_for token, SeparatorOn, { /^on$/ => :on }
45
52
  end
46
-
53
+
47
54
  def to_s
48
55
  'separator'
49
56
  end
50
57
  end
51
-
58
+
52
59
  class SeparatorComma < Separator #:nodoc:
53
60
  def to_s
54
61
  super << '-comma'
55
62
  end
56
63
  end
57
-
64
+
58
65
  class SeparatorSlashOrDash < Separator #:nodoc:
59
66
  def to_s
60
67
  super << '-slashordash-' << @type.to_s
61
68
  end
62
69
  end
63
-
70
+
64
71
  class SeparatorAt < Separator #:nodoc:
65
72
  def to_s
66
73
  super << '-at'
67
74
  end
68
75
  end
69
-
76
+
70
77
  class SeparatorIn < Separator #:nodoc:
71
78
  def to_s
72
79
  super << '-in'
73
80
  end
74
81
  end
75
82
 
83
+ class SeparatorOn < Separator #:nodoc:
84
+ def to_s
85
+ super << '-on'
86
+ end
87
+ end
76
88
  end
@@ -0,0 +1,31 @@
1
+ module Chronic
2
+ # A Span represents a range of time. Since this class extends
3
+ # Range, you can use #begin and #end to get the beginning and
4
+ # ending times of the span (they will be of class Time)
5
+ class Span < Range
6
+ # Returns the width of this span in seconds
7
+ def width
8
+ (self.end - self.begin).to_i
9
+ end
10
+
11
+ # Add a number of seconds to this span, returning the
12
+ # resulting Span
13
+ def +(seconds)
14
+ Span.new(self.begin + seconds, self.end + seconds)
15
+ end
16
+
17
+ # Subtract a number of seconds to this span, returning the
18
+ # resulting Span
19
+ def -(seconds)
20
+ self + -seconds
21
+ end
22
+
23
+ # Prints this span in a nice fashion
24
+ def to_s
25
+ '(' << self.begin.to_s << '..' << self.end.to_s << ')'
26
+ end
27
+
28
+ alias :cover? :include? unless RUBY_VERSION =~ /^1.9/
29
+
30
+ end
31
+ end
@@ -0,0 +1,42 @@
1
+ module Chronic
2
+ # Tokens are tagged with subclassed instances of this class when
3
+ # they match specific criteria
4
+ class Tag
5
+
6
+ # @return [Symbol]
7
+ attr_accessor :type
8
+
9
+ # @param [Symbol] type
10
+ def initialize(type)
11
+ @type = type
12
+ end
13
+
14
+ # @param [Time] s Set the start timestamp for this Tag
15
+ def start=(s)
16
+ @now = s
17
+ end
18
+
19
+ class << self
20
+ private
21
+
22
+ # @param [Token] token
23
+ # @param [Class] klass The class instance to create
24
+ # @param [Regexp, Hash] items
25
+ # @return [Object, nil] either a new instance of `klass` or `nil` if
26
+ # no match is found
27
+ def scan_for(token, klass, items={})
28
+ case items
29
+ when Regexp
30
+ return klass.new(token.word) if items =~ token.word
31
+ when Hash
32
+ items.each do |item, symbol|
33
+ return klass.new(symbol) if item =~ token.word
34
+ end
35
+ end
36
+ nil
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,30 @@
1
+ module Chronic
2
+ class TimeZone < Tag
3
+
4
+ # Scan an Array of {Token}s and apply any necessary TimeZone tags to
5
+ # each token
6
+ #
7
+ # @param [Array<Token>] tokens Array of tokens to scan
8
+ # @param [Hash] options Options specified in {Chronic.parse}
9
+ # @return [Array] list of tokens
10
+ def self.scan(tokens, options)
11
+ tokens.each do |token|
12
+ if t = scan_for_all(token) then token.tag(t); next end
13
+ end
14
+ end
15
+
16
+ # @param [Token] token
17
+ # @return [TimeZone, nil]
18
+ def self.scan_for_all(token)
19
+ scan_for token, self,
20
+ {
21
+ /[PMCE][DS]T|UTC/i => :tz,
22
+ /(tzminus)?\d{2}:?\d{2}/ => :tz
23
+ }
24
+ end
25
+
26
+ def to_s
27
+ 'timezone'
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,45 @@
1
+ module Chronic
2
+ class Token
3
+
4
+ # @return [String] The word this Token represents
5
+ attr_accessor :word
6
+
7
+ # @return [Array] A list of tag associated with this Token
8
+ attr_accessor :tags
9
+
10
+ def initialize(word)
11
+ @word = word
12
+ @tags = []
13
+ end
14
+
15
+ # Tag this token with the specified tag
16
+ #
17
+ # @param [Tag] new_tag An instance of {Tag} or one of its subclasses
18
+ def tag(new_tag)
19
+ @tags << new_tag
20
+ end
21
+
22
+ # Remove all tags of the given class
23
+ #
24
+ # @param [Class] The tag class to remove
25
+ def untag(tag_class)
26
+ @tags.delete_if { |m| m.kind_of? tag_class }
27
+ end
28
+
29
+ # @return [Boolean] true if this token has any tags
30
+ def tagged?
31
+ @tags.size > 0
32
+ end
33
+
34
+ # @param [Class] tag_class The tag class to search for
35
+ # @return [Tag] The first Tag that matches the given class
36
+ def get_tag(tag_class)
37
+ @tags.find { |m| m.kind_of? tag_class }
38
+ end
39
+
40
+ # Print this Token in a pretty way
41
+ def to_s
42
+ @word << '(' << @tags.join(', ') << ') '
43
+ end
44
+ end
45
+ end
data/lib/chronic.rb CHANGED
@@ -1,14 +1,84 @@
1
- #=============================================================================
1
+ require 'time'
2
+ require 'date'
3
+
4
+ # Parse natural language dates and times into Time or {Chronic::Span} objects
5
+ #
6
+ # @example
7
+ # require 'chronic'
8
+ #
9
+ # Time.now #=> Sun Aug 27 23:18:25 PDT 2006
10
+ #
11
+ # Chronic.parse('tomorrow')
12
+ # #=> Mon Aug 28 12:00:00 PDT 2006
13
+ #
14
+ # Chronic.parse('monday', :context => :past)
15
+ # #=> Mon Aug 21 12:00:00 PDT 2006
16
+ #
17
+ # Chronic.parse('this tuesday 5:00')
18
+ # #=> Tue Aug 29 17:00:00 PDT 2006
19
+ #
20
+ # Chronic.parse('this tuesday 5:00', :ambiguous_time_range => :none)
21
+ # #=> Tue Aug 29 05:00:00 PDT 2006
2
22
  #
3
- # Name: Chronic
4
- # Author: Tom Preston-Werner
5
- # Purpose: Parse natural language dates and times into Time or
6
- # Chronic::Span objects
23
+ # Chronic.parse('may 27th', :now => Time.local(2000, 1, 1))
24
+ # #=> Sat May 27 12:00:00 PDT 2000
7
25
  #
8
- #=============================================================================
26
+ # Chronic.parse('may 27th', :guess => false)
27
+ # #=> Sun May 27 00:00:00 PDT 2007..Mon May 28 00:00:00 PDT 2007
28
+ #
29
+ # @author Tom Preston-Werner, Lee Jarvis
30
+ module Chronic
31
+ VERSION = "0.6.5"
32
+
33
+ class << self
34
+
35
+ # @return [Boolean] true when debug mode is enabled
36
+ attr_accessor :debug
37
+
38
+ # @example
39
+ # require 'chronic'
40
+ # require 'active_support/time'
41
+ #
42
+ # Time.zone = 'UTC'
43
+ # Chronic.time_class = Time.zone
44
+ # Chronic.parse('June 15 2006 at 5:54 AM')
45
+ # # => Thu, 15 Jun 2006 05:45:00 UTC +00:00
46
+ #
47
+ # @return [Time] The time class Chronic uses internally
48
+ attr_accessor :time_class
49
+
50
+ # The current Time Chronic is using to base from
51
+ #
52
+ # @example
53
+ # Time.now #=> 2011-06-06 14:13:43 +0100
54
+ # Chronic.parse('yesterday') #=> 2011-06-05 12:00:00 +0100
55
+ #
56
+ # now = Time.local(2025, 12, 24)
57
+ # Chronic.parse('tomorrow', :now => now) #=> 2025-12-25 12:00:00 +0000
58
+ #
59
+ # @return [Time, nil]
60
+ attr_accessor :now
61
+ end
62
+
63
+ self.debug = false
64
+ self.time_class = Time
65
+ end
9
66
 
10
67
  require 'chronic/chronic'
68
+ require 'chronic/handler'
11
69
  require 'chronic/handlers'
70
+ require 'chronic/mini_date'
71
+ require 'chronic/tag'
72
+ require 'chronic/span'
73
+ require 'chronic/token'
74
+ require 'chronic/grabber'
75
+ require 'chronic/pointer'
76
+ require 'chronic/scalar'
77
+ require 'chronic/ordinal'
78
+ require 'chronic/separator'
79
+ require 'chronic/time_zone'
80
+ require 'chronic/numerizer'
81
+ require 'chronic/season'
12
82
 
13
83
  require 'chronic/repeater'
14
84
  require 'chronic/repeaters/repeater_year'
@@ -19,6 +89,7 @@ require 'chronic/repeaters/repeater_month_name'
19
89
  require 'chronic/repeaters/repeater_fortnight'
20
90
  require 'chronic/repeaters/repeater_week'
21
91
  require 'chronic/repeaters/repeater_weekend'
92
+ require 'chronic/repeaters/repeater_weekday'
22
93
  require 'chronic/repeaters/repeater_day'
23
94
  require 'chronic/repeaters/repeater_day_name'
24
95
  require 'chronic/repeaters/repeater_day_portion'
@@ -27,21 +98,14 @@ require 'chronic/repeaters/repeater_minute'
27
98
  require 'chronic/repeaters/repeater_second'
28
99
  require 'chronic/repeaters/repeater_time'
29
100
 
30
- require 'chronic/grabber'
31
- require 'chronic/pointer'
32
- require 'chronic/scalar'
33
- require 'chronic/ordinal'
34
- require 'chronic/separator'
101
+ class Time
102
+ def self.construct(year, month = 1, day = 1, hour = 0, minute = 0, second = 0)
103
+ warn "Chronic.construct will be deprecated in version 0.7.0. Please use Chronic.construct instead"
104
+ Chronic.construct(year, month, day, hour, minute, second)
105
+ end
35
106
 
36
- module Chronic
37
- VERSION = "0.1.5"
38
-
39
- def self.debug; false; end
107
+ def to_minidate
108
+ warn "Time.to_minidate will be deprecated in version 0.7.0. Please use Chronic::MiniDate.from_time(time) instead"
109
+ Chronic::MiniDate.from_time(self)
110
+ end
40
111
  end
41
-
42
- alias p_orig p
43
-
44
- def p(val)
45
- p_orig val
46
- puts
47
- end
data/test/helper.rb ADDED
@@ -0,0 +1,6 @@
1
+ unless defined? Chronic
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'chronic'
4
+ end
5
+
6
+ require 'test/unit'