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-3.0.4 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.0.3 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.0.2 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.0.1 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.0.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.12.3 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.12.2 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.12.1 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.12.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.11.1 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.11.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.10.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.9.1 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.8.2 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.8.1 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.8.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.7.1 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.7.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.6.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-2.5.0 lib/cocoa/sugarcube-nsdate/nsstring.rb