Changeset 287


Ignore:
Timestamp:
Sep 23, 2009, 3:45:32 PM (10 years ago)
Author:
KOBAYASHI, Shinji
Message:

iso8601 date time 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

    r285 r287  
    339339
    340340      def self.valid_iso8601_time?(s)
    341         if /^(\d{2}):?(\d{2})?(:?)(\d{2})?((\.|,)(\d+))?(T?)(Z|([+-](\d{2}):?(\d{2})))?$/ =~ s
     341        if /^(\d{2}):?(\d{2})?(:?)(\d{2})?((\.|,)(\d+))?(Z|([+-](\d{2}):?(\d{2})))?$/ =~ s
    342342# ISO 8601 regular expression by H. Yuki
    343343#  http://digit.que.ne.jp/work/wiki.cgi?Perl%E3%83%A1%E3%83%A2%2FW3C%E5%BD%A2%E5%BC%8F%E3%81%AE%E6%97%A5%E6%99%82%E3%81%AE%E8%A7%A3%E6%9E%90
    344344# (\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d))?)?(Z|([+-]\d{2}):(\d{2}))?)?)?)?
    345           hh = $1; mm = $2; ss = $4; msec = $7; tz = $9
     345          hh = $1; mm = $2; ss = $4; msec = $7; tz = $8
    346346          if hh.to_i == HOURS_IN_DAY and (mm.nil? or mm.to_i == 0) and (ss.nil? or ss.to_i == 0) and (msec.nil? or msec.to_i==0)
    347347            return true
     
    410410      include ISO8601DateTimeModule
    411411      def initialize(string)
    412         /(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|([+-]\d{2}):?(\d{2}))?)?)?)?/ =~ string
    413         if $1.empty?
     412        unless /(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|([+-]\d{2}):?(\d{2}))?)?)?)?/ =~ string
    414413          raise ArgumentError, 'format invalid'
    415414        else
Note: See TracChangeset for help on using the changeset viewer.