0
class TestParsing < Test::Unit::TestCase
0
@@ -70,6 +69,9 @@ class TestParsing < Test::Unit::TestCase
0
#time = parse_now("January 12, '00")
0
#assert_equal Time.local(2000, 1, 12, 12), time
0
+ time = parse_now("may 27, 1979")
0
+ assert_equal Time.local(1979, 5, 27, 12), time
0
time = parse_now("may 27 79")
0
assert_equal Time.local(1979, 5, 27, 12), time
0
@@ -87,6 +89,9 @@ class TestParsing < Test::Unit::TestCase
0
time = parse_now("3 jan 2010 4pm")
0
assert_equal Time.local(2010, 1, 3, 16), time
0
+ time = parse_now("27 Oct 2006 7:30pm")
0
+ assert_equal Time.local(2006, 10, 27, 19, 30), time
0
time = parse_now("5/27/1979")
0
@@ -140,7 +145,7 @@ class TestParsing < Test::Unit::TestCase
0
time = parse_now("Mon Apr 02 17:00:00 PDT 2007")
0
- assert_equal
Time.local(2007, 4, 2, 17), time0
+ assert_equal
1175558400, time.to_i0
time = parse_now(now.to_s)
0
@@ -163,10 +168,6 @@ class TestParsing < Test::Unit::TestCase
0
- Chronic.parse('two months ago this friday')
0
time = parse_now("friday")
0
assert_equal Time.local(2006, 8, 18, 12), time
0
@@ -424,6 +425,12 @@ class TestParsing < Test::Unit::TestCase
0
time = parse_now("tomorrow morning at 5:30")
0
assert_equal Time.local(2006, 8, 17, 5, 30), time
0
+ time = parse_now("next monday at 12:01 am")
0
+ assert_equal Time.local(2006, 8, 21, 00, 1), time
0
+ time = parse_now("next monday at 12:01 pm")
0
+ assert_equal Time.local(2006, 8, 21, 12, 1), time
0
def test_parse_guess_rgr
0
@@ -563,6 +570,9 @@ class TestParsing < Test::Unit::TestCase
0
def test_parse_guess_nonsense
0
time = parse_now("some stupid nonsense")
0
+ time = parse_now("Ham Sandwich")
0
+ assert_equal nil, time
0
@@ -591,6 +601,11 @@ class TestParsing < Test::Unit::TestCase
0
assert_equal parse_now("meeting today at 2pm"), @time_2006_08_16_14_00_00
0
+ assert_equal Time.local(2006, 8, 16), parse_now("8/16/2006 at 12am")
0
+ assert_equal Time.local(2006, 8, 16, 12), parse_now("8/16/2006 at 12pm")
0
def test_argument_validation
0
assert_raise(Chronic::InvalidArgumentException) do
0
time = Chronic.parse("may 27", :foo => :bar)
0
@@ -601,6 +616,31 @@ class TestParsing < Test::Unit::TestCase
0
+ # assert_equal '', parse_now("2 hours")
0
+ def test_days_in_november
0
+ t1 = Chronic.parse('1st thursday in november', :now => Time.local(2007))
0
+ assert_equal Time.local(2007, 11, 1, 12), t1
0
+ t1 = Chronic.parse('1st friday in november', :now => Time.local(2007))
0
+ assert_equal Time.local(2007, 11, 2, 12), t1
0
+ t1 = Chronic.parse('1st saturday in november', :now => Time.local(2007))
0
+ assert_equal Time.local(2007, 11, 3, 12), t1
0
+ t1 = Chronic.parse('1st sunday in november', :now => Time.local(2007))
0
+ assert_equal Time.local(2007, 11, 4, 11), t1
0
+ # Chronic.debug = true
0
+ # t1 = Chronic.parse('1st monday in november', :now => Time.local(2007))
0
+ # assert_equal Time.local(2007, 11, 5, 11), t1
0
def parse_now(string, options={})
0
Chronic.parse(string, {:now => TIME_2006_08_16_14_00_00 }.merge(options))
Comments
No one has commented yet.