Hi I would like to define a date object by specifying week:- * year * week (1-52) * day-of-week (1-7) The ISO standard specifies * weeks start on a monday * week 1 of a given year is the one that includes the first Thursday of that year. (or, equivalently, week 1 is the week that includes 4 January.) Does anyone have any code for this? Peter _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
This looks like it works (after hasty testing) def datebyweek(year,week,dayofweek) # ISO defines W1 as containing Jan 4th Time.local(year,1,4,00,00,00).at_beginning_of_week + ((week-1) * 604800) + ((dayofweek-1) * 86400) end _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails