Skip to content

Instantly share code, notes, and snippets.

@asaaki
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asaaki/f3b20b3e28101df1784d to your computer and use it in GitHub Desktop.
Save asaaki/f3b20b3e28101df1784d to your computer and use it in GitHub Desktop.
Timezones: float offset to numerical string presentation of zone
module ZoneConversion
module_function
def float2zone(offset)
("%+06.2f" % offset).tr(".", ":")
end
end
### Example
offset = 4.0
ZoneConversion.float2zone(offset)
#=> "+04:00"
offset = -8.0
ZoneConversion.float2zone(offset)
#=> "-08:00"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment