Flowdock
method

_parse_ddd

Importance_0
_parse_ddd(str, e) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/date/format.rb, line 887
  def self._parse_ddd(str, e) # :nodoc:
    if str.sub!(
                /([-+]?)(\d{2,14})
                  (?:
                    \s*
                    T?
                    \s*
                    (\d{2,6})(?:[,.](\d*))?
                  )?
                  (?:
                    \s*
                    (
                      Z
                    |
                      [-+]\d{1,4}
                    )
                    \b
                  )?
                /inx,
                ' ')
      case $2.size
      when 2
        e.mday = $2[ 0, 2].to_i
      when 4
        e.mon  = $2[ 0, 2].to_i
        e.mday = $2[ 2, 2].to_i
      when 6
        e.year = ($1 + $2[ 0, 2]).to_i
        e.mon  = $2[ 2, 2].to_i
        e.mday = $2[ 4, 2].to_i
      when 8, 10, 12, 14
        e.year = ($1 + $2[ 0, 4]).to_i
        e.mon  = $2[ 4, 2].to_i
        e.mday = $2[ 6, 2].to_i
        e.hour = $2[ 8, 2].to_i if $2.size >= 10
        e.min  = $2[10, 2].to_i if $2.size >= 12
        e.sec  = $2[12, 2].to_i if $2.size >= 14
        e._comp = false
      when 3
        e.yday = $2[ 0, 3].to_i
      when 5
        e.year = ($1 + $2[ 0, 2]).to_i
        e.yday = $2[ 2, 3].to_i
      when 7
        e.year = ($1 + $2[ 0, 4]).to_i
        e.yday = $2[ 4, 3].to_i
      end
      if $3
        case $3.size
        when 2, 4, 6
          e.hour = $3[ 0, 2].to_i
          e.min  = $3[ 2, 2].to_i if $3.size >= 4
          e.sec  = $3[ 4, 2].to_i if $3.size >= 6
        end
      end
      if $4
        e.sec_fraction = $4.to_i.to_r / (10**$4.size)
      end
      if $5
        e.zone = $5
      end
      true
    end
  end
Register or log in to add new notes.