jruby-rfc2445 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,6 +53,20 @@ class ICalParseUtil
53
53
  result
54
54
  end
55
55
 
56
+ # Parse a RECURRENCE-ID into a JTime. Various formats of this property
57
+ # are permitted, except for the "range" parameter
58
+
59
+ def parse_recurrence_id(s, tzid = 'UTC')
60
+ raise ArgumentError, 'range parameter not supported' if s =~ /RANGE=/
61
+
62
+ s =~ /TZID=([^:;]+)/
63
+ tzid = $1 || tzid
64
+
65
+ # Clean up ISO 8601 format and extra parameters
66
+ s = s.gsub(/;[^:]+:|[\-:]/, '')
67
+ parse_jtime(s, tzid)
68
+ end
69
+
56
70
  def parse_datetime(s)
57
71
  s =~ /(;TZID=([^\s]+))?:([^\s]+)/
58
72
  parse_jtime($3, $2)
@@ -432,6 +432,23 @@ describe ICalParseUtil do
432
432
  jtime.should be_instance_of(JTime)
433
433
  jtime.hour.should == 0
434
434
  end
435
+
436
+ it "should parse recurrence-id into JTime" do
437
+ jtime = ICalParseUtil.parse_recurrence_id('2010-02-11T02:00:00Z')
438
+ jtime.should == JTime.utc(2010, 2, 11, 2)
439
+
440
+ jtime = ICalParseUtil.parse_recurrence_id(';VALUE=DATE:20100211')
441
+ jtime.should == JTime.utc(2010, 2, 11)
442
+
443
+ jtime = ICalParseUtil.parse_recurrence_id(';VALUE=DATE-TIME:20100211T020000Z')
444
+ jtime.should == JTime.utc(2010, 2, 11, 2)
445
+
446
+ jtime = ICalParseUtil.parse_recurrence_id(';VALUE=DATE-TIME:2010-02-11T02:00:00Z')
447
+ jtime.should == JTime.utc(2010, 2, 11, 2)
448
+
449
+ jtime = ICalParseUtil.parse_recurrence_id(';TZID=America/Los_Angeles;VALUE=DATE:20100211')
450
+ jtime.should == JTime.utc(2010, 2, 11, 8)
451
+ end
435
452
  end
436
453
 
437
454
  describe RecurrenceTime do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-rfc2445
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerry Luk