Skip to content

Instantly share code, notes, and snippets.

@karlosmid
Created January 31, 2015 17:23
Show Gist options
  • Save karlosmid/b8b788dd0bf2c6f9f663 to your computer and use it in GitHub Desktop.
Save karlosmid/b8b788dd0bf2c6f9f663 to your computer and use it in GitHub Desktop.
us week number in pure ruby
def us_week_number us_date
week = Time.local(us_date.year,us_date.month,us_date.day).strftime("%U").to_i
if week == 0
Time.local(us_date.year - 1,12,31).strftime("%U").to_i
else
week
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment