Changeset 288 for ruby/branches


Ignore:
Timestamp:
Sep 23, 2009, 4:33:50 PM (15 years ago)
Author:
KOBAYASHI, Shinji
Message:

timezone completed

Location:
ruby/branches/0.5
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • ruby/branches/0.5/lib/open_ehr/assumed_library_types.rb

    r287 r288  
    453453    end
    454454 
    455     class ISO8601_TIMEZONE
     455    class ISO8601Timezone
    456456      attr_accessor :sign, :hour, :minute
    457457
     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
    458469      def is_gmt?
    459         @sign == "+1" and @hour == 0 and @minute == 0
     470        @sign == +1 and @hour == 0 and @minute == 0
    460471      end
    461472
    462473      def as_string
    463         if @sign == "+1"
     474        if @sign == +1
    464475          s = "+"
    465         elsif @sign == "-1"
     476        elsif @sign == -1
    466477          s = "-"
    467478        end
    468         sprintf("Z%s%02d%02d", s, @hour, @minute)
    469       end
    470     end # end of ISO8601_TIMEZONE
     479        sprintf("%s%02d%02d", s, @hour, @minute)
     480      end
     481    end # end of ISO8601Timezone
    471482
    472483    module ISO8601_DURATION_MODULE
Note: See TracChangeset for help on using the changeset viewer.