Skip to content

Commit

Permalink
added ZuluDateTime property for use by change management properties
Browse files Browse the repository at this point in the history
  • Loading branch information
rubyredrick committed Apr 15, 2010
1 parent 8f4946b commit 77aa811
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
6 changes: 3 additions & 3 deletions component_attributes/component_property_defs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,16 @@ trigger:
rfc_ref: '4.8.6.3 p 127-129'
created:
purpose: This property specifies the date and time that the calendar information was created by teh calendar user agent in the calendar store.
type: DateTime
type: ZuluDateTime
rfc_ref: '4.8.7.1 pp 129-130'
dtstamp:
purpose: This property indicates the date/time that the instance of the iCalendar object was created.
type: DateTime
type: ZuluDateTime
auto_set: to_ical
rfc_ref: '4.8.7.2 pp 130-131'
last-modified:
purpose: This property specifies the date and time that the information associated with the calendar component was last revised in teh calendar store.
type: DateTime
type: ZuluDateTime
rfc_ref: '4.8.7.3 p 131'
sequence:
purpose: This property defines the revision sequence number of the calendar component within a sequence of revisions.
Expand Down
8 changes: 8 additions & 0 deletions lib/ri_cal/fast_date_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ def change(options)
# end
# end

def utc
if offset == 0
self
else
advance(:seconds => -offset, :offset => 0)
end
end

def hms_to_seconds(hours, minutes, seconds)
seconds + 60 *(minutes + (60 * hours))
end
Expand Down
16 changes: 16 additions & 0 deletions lib/ri_cal/property_value/ZuluDateTime.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'date'
module RiCal
class PropertyValue
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
#
# RiCal::PropertyValue::CalAddress represents an icalendar CalAddress property value
# which is defined in RFC 2445 section 4.3.5 pp 35-37
class ZuluDateTime < PropertyValue::DateTime

def value=(val) # :nodoc:
super
@date_time_value = @date_time_value.utc if @date_time_value
end
end
end
end
10 changes: 10 additions & 0 deletions spec/ri_cal/fast_date_time_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
module RiCal

describe RiCal::FastDateTime do
context "#utc" do
it "should not change if it is already UTC" do
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).utc.should == FastDateTime.new(2009, 5, 29, 19, 3, 0, 0)
end

it "should change the time by the offset" do
FastDateTime.new(2010, 4, 15, 16, 3, 0, -4*60*60).utc.should == FastDateTime.new(2010, 4, 15, 20, 3, 0, 0)
end
end

context "#==" do
it "should detect equal FastDateTimes" do
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).should ==
Expand Down

0 comments on commit 77aa811

Please sign in to comment.