broadcast_calendar 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/broadcast_calendar/version.rb +1 -1
- data/lib/broadcast_calendar.rb +20 -0
- data/spec/broadcast_calendar_spec.rb +11 -1
- metadata +4 -4
data/lib/broadcast_calendar.rb
CHANGED
@@ -18,4 +18,24 @@ module BroadcastCalendar
|
|
18
18
|
|
19
19
|
beginning..ending
|
20
20
|
end
|
21
|
+
|
22
|
+
def month_and_year_for(date)
|
23
|
+
range = dates_for(date.month,date.year)
|
24
|
+
|
25
|
+
month = date.month
|
26
|
+
year = date.year
|
27
|
+
|
28
|
+
unless range.cover?(date)
|
29
|
+
month += (date <=> range.begin)
|
30
|
+
if month < 1
|
31
|
+
month = 12
|
32
|
+
year -= 1
|
33
|
+
elsif month > 12
|
34
|
+
month = 1
|
35
|
+
year += 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
[month,year]
|
40
|
+
end
|
21
41
|
end
|
@@ -46,11 +46,21 @@ describe BroadcastCalendar do
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
|
49
|
-
it "converts
|
49
|
+
it "converts months and years to ranges" do
|
50
50
|
dates.each do |year,months|
|
51
51
|
months.each do |month,range|
|
52
52
|
BroadcastCalendar.dates_for(month,year).should == range
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
it "returns the broadcast month and year for a given year" do
|
58
|
+
dates.each do |year,months|
|
59
|
+
months.each do |month,range|
|
60
|
+
range.each do |date|
|
61
|
+
BroadcastCalendar.month_and_year_for(date).should == [month,year]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
56
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: broadcast_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-07-03 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153830380 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153830380
|
26
26
|
description: Library tht returns the beginning and ending Gregorian (civil) dates
|
27
27
|
for months in the broadcast calendar.
|
28
28
|
email: mike@subelsky.com
|