Created
January 31, 2015 17:23
-
-
Save karlosmid/b8b788dd0bf2c6f9f663 to your computer and use it in GitHub Desktop.
us week number in pure ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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