broadcast_calendar 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module BroadcastCalendar
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -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 2010 dates" do
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.0.0
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-06-21 00:00:00.000000000 -04:00
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: &2153156480 !ruby/object:Gem::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: *2153156480
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