Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6093

Show
Ignore:
Timestamp:
01/30/07 18:15:58 (2 years ago)
Author:
xal
Message:

Added TimeZone#offset which always returns +HH:MM format offset of the timezone, even if the utc_offset is zero

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/tzinfo_timezone/lib/tzinfo_timezone.rb

    r5198 r6093  
    162162  # result. 
    163163  def formatted_offset(colon=true) 
    164     return "" if utc_offset == 0 
     164    utc_offset == 0 ? '' : offset(colon) 
     165  end 
     166   
     167  # Returns the offset of this time zone as a formatted string, of the 
     168  # format "+HH:MM". 
     169  def offset(colon=true) 
    165170    sign = (utc_offset < 0 ? -1 : 1) 
    166171    hours = utc_offset.abs / 3600 
     
    168173    "%+03d%s%02d" % [ hours * sign, colon ? ":" : "", minutes ] 
    169174  end 
    170  
     175   
    171176  # Compute and return the current time, in the time zone represented by 
    172177  # +self+.