Skip to content

Instantly share code, notes, and snippets.

@karlosmid
Last active August 29, 2015 14:08
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 karlosmid/cbe53925db3383f9efd4 to your computer and use it in GitHub Desktop.
Save karlosmid/cbe53925db3383f9efd4 to your computer and use it in GitHub Desktop.
US week number implementation in IronRuby
def us_week_number us_date
date_time_formatinfo_in_dot_net = System::Globalization::DateTimeFormatInfo.new
date_time_formatinfo_in_dot_net.CalendarWeekRule = System::Globalization::CalendarWeekRule.FirstFullWeek
my_calendar = date_time_formatinfo_in_dot_net.Calendar
us_date_dot_net_instance = System::DateTime.parse(us_date.strftime('%Y/%m/%d'))
my_calendar.GetWeekOfYear(us_date_dot_net_instance,date_time_formatinfo_in_dot_net.CalendarWeekRule,date_time_formatinfo_in_dot_net.FirstDayOfWeek)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment