Skip to content

Commit

Permalink
new file: scripts/Rosettacode/Last_Sunday_of_each_month.sf
Browse files Browse the repository at this point in the history
  • Loading branch information
trizen committed Sep 10, 2015
1 parent 6a39c5b commit ce4fac6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ scripts/Rosettacode/Knapsack_problem_Continuous.sf
scripts/Rosettacode/Knuth_shuffle.sf
scripts/Rosettacode/Langton's_ant.sf
scripts/Rosettacode/Largest_int_from_concatenated_ints.sf
scripts/Rosettacode/Last_Sunday_of_each_month.sf
scripts/Rosettacode/Leap_year.sf
scripts/Rosettacode/Leap_year_1.sf
scripts/Rosettacode/Letter_frequency.sf
Expand Down
22 changes: 22 additions & 0 deletions scripts/Rosettacode/Last_Sunday_of_each_month.sf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/ruby

#
## http://rosettacode.org/wiki/Find_the_last_Sunday_of_each_month
#

require 'DateTime';

var (year=2015) = ARGV»to_i»()...;

range(1, 12).each { |i|
var date = %s'DateTime'.last_day_of_month(
year => year,
month => i
);

while (date.dow != 7) {
[date.subtract(days => 1)] » \date;
};

say date.ymd;
}

0 comments on commit ce4fac6

Please sign in to comment.