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-4.0.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.5.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.4.2 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.4.1 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.4.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.3.7 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.3.6 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.3.5 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.3.4 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.3.3 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.3.2 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.3.1 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.3.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.2.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.1.1 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.1.0 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.0.8 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.0.7 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.0.6 lib/cocoa/sugarcube-nsdate/nsstring.rb
sugarcube-3.0.5 lib/cocoa/sugarcube-nsdate/nsstring.rb