Sha256: 59de80ac7bbd7e799f55abc62e96473729f8285b759bc89348cb260373a49812

Contents?: true

Size: 520 Bytes

Versions: 88

Compression:

Stored size: 520 Bytes

Contents

class NSString

  # checks ISO8601 formats *before* falling back on natural language detection
  def nsdate
    SugarCube::DateParser.iso8601(self) || SugarCube::DateParser.parse_date(self)
  end

  def nstimezone
    case self
    when /([+-]?\d{4})/
      sec = $1[-4,2].to_i * 3600
      NSTimeZone.timeZoneForSecondsFromGMT(sec)
    when /(GMT|UTC)([+-]\d{1,2})?/
      sec = $2 ? $2.to_i * 3600 : 0
      NSTimeZone.timeZoneForSecondsFromGMT(sec)
    else
      NSTimeZone.timeZoneWithName(self)
    end
  end

end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
sugarcube-1.5.8 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.5.7 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.5.6 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.5.5 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.5.4 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.5.3 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.5.2 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.5.1 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.5.0 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.4.6 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.4.5 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.4.4 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.4.3 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.4.2 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.4.1 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.4.0 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.3.11 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.3.10 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.3.9 lib/sugarcube-nsdate/nsstring.rb
sugarcube-1.3.8 lib/sugarcube-nsdate/nsstring.rb