Skip to content

Instantly share code, notes, and snippets.

@benjaminws
Created January 16, 2013 21:33
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 benjaminws/4551147 to your computer and use it in GitHub Desktop.
Save benjaminws/4551147 to your computer and use it in GitHub Desktop.
def new_time(timestamp, options)
Time.new(
options[:year] || timestamp.year,
options[:month] || timestamp.month,
options[:day] || timestamp.day,
options[:hour] || timestamp.hour,
options[:min] || (options[:hour] ? 0 : timestamp.min),
options[:sec] || ((options[:hour] || options[:min]) ? 0 : timestamp.sec),
timestamp.gmt_offset
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment