Changeset 288 for ruby/branches/0.5/lib/open_ehr/assumed_library_types.rb
- Timestamp:
- Sep 23, 2009, 4:33:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/branches/0.5/lib/open_ehr/assumed_library_types.rb
r287 r288 453 453 end 454 454 455 class ISO8601 _TIMEZONE455 class ISO8601Timezone 456 456 attr_accessor :sign, :hour, :minute 457 457 458 def initialize(string) 459 unless /(Z|(([+-])(\d{2}):?(\d{2})))/ =~ string 460 raise ArgumentError, 'invaild format' 461 end 462 if $1 == 'Z' 463 @sign, @hour, @minute = +1, 0, 0 464 else 465 @sign, @hour, @minute = ($3+'1').to_i, $4.to_i , $5.to_i 466 end 467 end 468 458 469 def is_gmt? 459 @sign == "+1"and @hour == 0 and @minute == 0470 @sign == +1 and @hour == 0 and @minute == 0 460 471 end 461 472 462 473 def as_string 463 if @sign == "+1"474 if @sign == +1 464 475 s = "+" 465 elsif @sign == "-1"476 elsif @sign == -1 466 477 s = "-" 467 478 end 468 sprintf(" Z%s%02d%02d", s, @hour, @minute)469 end 470 end # end of ISO8601 _TIMEZONE479 sprintf("%s%02d%02d", s, @hour, @minute) 480 end 481 end # end of ISO8601Timezone 471 482 472 483 module ISO8601_DURATION_MODULE
Note:
See TracChangeset
for help on using the changeset viewer.