timetress 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in timetress.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Katrina Owen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # Timetress
2
+
3
+ Knows about workdays and holidays, public and otherwise.
4
+ Answers the age-old question _When is mothersday this year?_.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'timetress'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install timetress
19
+
20
+ ## Usage
21
+
22
+ ### Timetress knows about holidays
23
+
24
+ ```
25
+ Timetress.mothersday 2012
26
+ => #<Date: 2012-02-12>
27
+ ```
28
+
29
+ ```
30
+ # In October of 2011
31
+ Timetress.next_mothersday
32
+ => #<Date: 2012-02-12>
33
+ ```
34
+
35
+ ### Public Holidays
36
+
37
+ > A public holiday, national holiday or legal holiday is a holiday generally established by law and is usually a non-working day during the year.
38
+ > - Wikipedia
39
+
40
+ Timetress::Norway.public_holidays(2012)
41
+ => [#<Date: 2012-01-01>, #<Date: 2012-04-05>,...]
42
+
43
+ ### Workdays
44
+
45
+ A workday is a day of the week which is neither a weekend, nor a public holiday.
46
+
47
+ ```
48
+ Timetress::Norway.workday? Date.new(2012, 1, 5)
49
+ => true
50
+
51
+ Timetress::Norway.workday? Date.new(2012, 5, 17)
52
+ => false
53
+ ```
54
+
55
+ In calculating deadlines and lead time, it's often helpful to count workdays:
56
+
57
+ ```
58
+ Timetress::Norway.nth_workday_before 4, Date.new(2012, 10, 25)
59
+ => #<Date: 2012-10-19>
60
+
61
+ Timetress::Norway.nth_workday_after 1, Date.new(2012, 10, 25)
62
+ => #<Date: 2012-10-26>
63
+ ```
64
+
65
+ ## Implemented holidays (Norway)
66
+
67
+ Public holidays are emphasized.
68
+
69
+ * *New Year's Day*: January 1st.
70
+ * Mothersday: Second Sunday in February.
71
+ * Valentines Day: February 14.
72
+ * *Labour Day*: May 1.
73
+ * *National Holiday*: May 17.
74
+ * *Maundy Thursday*: The Thursday before Easter Sunday.
75
+ * *Good Friday*: The Friday before Easter Sunday.
76
+ * *Easter Sunday*: Don't ask. It's crazy.
77
+ * *Easter Monday*: The day after Easter Sunday.
78
+ * *Ascension*: The Thursday which is the 40th day after Easter.
79
+ * *Pentecost Sunday*: The Sunday which is the 50th day after Easter.
80
+ * *Pentecost Monday*: The Sunday which is the 51st day after Easter.
81
+ * Fathersday: Second Sunday in November.
82
+ * Christmas Eve: December 24th.
83
+ * *Christmas*: December 25th.
84
+ * *Boxing Day*: December 26th.
85
+
86
+ ## Easter
87
+
88
+ The cycle of Easter dates repeats after exactly 5,700,000 years, with April 19 being the most common date.
89
+
90
+ http://en.wikipedia.org/wiki/Computus
91
+
92
+ The current implementation simply has a list of 200 years worth of easter.
93
+
94
+ ## Contributing
95
+
96
+ 1. Fork it
97
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
98
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
99
+ 4. Push to the branch (`git push origin my-new-feature`)
100
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/timetress.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'date'
2
+ require "timetress/version"
3
+ require "timetress/easter"
4
+ require "timetress/holiday"
5
+ require "timetress/workday"
6
+
7
+ require 'timetress/norway'
8
+
9
+ module Timetress
10
+ extend Timetress::Holiday
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ module Timetress
2
+
3
+ dates = [ "1900-04-15", "1901-04-07", "1902-03-30", "1903-04-12", "1904-04-03", "1905-04-23", "1906-04-15", "1907-03-31", "1908-04-19", "1909-04-11", "1910-03-27", "1911-04-16", "1912-04-07", "1913-03-23", "1914-04-12", "1915-04-04", "1916-04-23", "1917-04-08", "1918-03-31", "1919-04-20", "1920-04-04", "1921-03-27", "1922-04-16", "1923-04-01", "1924-04-20", "1925-04-12", "1926-04-04", "1927-04-17", "1928-04-08", "1929-03-31", "1930-04-20", "1931-04-05", "1932-03-27", "1933-04-16", "1934-04-01", "1935-04-21", "1936-04-12", "1937-03-28", "1938-04-17", "1939-04-09", "1940-03-24", "1941-04-13", "1942-04-05", "1943-04-25", "1944-04-09", "1945-04-01", "1946-04-21", "1947-04-06", "1948-03-28", "1949-04-17", "1950-04-09", "1951-03-25", "1952-04-13", "1953-04-05", "1954-04-18", "1955-04-10", "1956-04-01", "1957-04-21", "1958-04-06", "1959-03-29", "1960-04-17", "1961-04-02", "1962-04-22", "1963-04-14", "1964-03-29", "1965-04-18", "1966-04-10", "1967-03-26", "1968-04-14", "1969-04-06", "1970-03-29", "1971-04-11", "1972-04-02", "1973-04-22", "1974-04-14", "1975-03-30", "1976-04-18", "1977-04-10", "1978-03-26", "1979-04-15", "1980-04-06", "1981-04-19", "1982-04-11", "1983-04-03", "1984-04-22", "1985-04-07", "1986-03-30", "1987-04-19", "1988-04-03", "1989-03-26", "1990-04-15", "1991-03-31", "1992-04-19", "1993-04-11", "1994-04-03", "1995-04-16", "1996-04-07", "1997-03-30", "1998-04-12", "1999-04-04", "2000-04-23", "2001-04-15", "2002-03-31", "2003-04-20", "2004-04-11", "2005-03-27", "2006-04-16", "2007-04-08", "2008-03-23", "2009-04-12", "2010-04-04", "2011-04-24", "2012-04-08", "2013-03-31", "2014-04-20", "2015-04-05", "2016-03-27", "2017-04-16", "2018-04-01", "2019-04-21", "2020-04-12", "2021-04-04", "2022-04-17", "2023-04-09", "2024-03-31", "2025-04-20", "2026-04-05", "2027-03-28", "2028-04-16", "2029-04-01", "2030-04-21", "2031-04-13", "2032-03-28", "2033-04-17", "2034-04-09", "2035-03-25", "2036-04-13", "2037-04-05", "2038-04-25", "2039-04-10", "2040-04-01", "2041-04-21", "2042-04-06", "2043-03-29", "2044-04-17", "2045-04-09", "2046-03-25", "2047-04-14", "2048-04-05", "2049-04-18", "2050-04-10", "2051-04-02", "2052-04-21", "2053-04-06", "2054-03-29", "2055-04-18", "2056-04-02", "2057-04-22", "2058-04-14", "2059-03-30", "2060-04-18", "2061-04-10", "2062-03-26", "2063-04-15", "2064-04-06", "2065-03-29", "2066-04-11", "2067-04-03", "2068-04-22", "2069-04-14", "2070-03-30", "2071-04-19", "2072-04-10", "2073-03-26", "2074-04-15", "2075-04-07", "2076-04-19", "2077-04-11", "2078-04-03", "2079-04-23", "2080-04-07", "2081-03-30", "2082-04-19", "2083-04-04", "2084-03-26", "2085-04-15", "2086-03-31", "2087-04-20", "2088-04-11", "2089-04-03", "2090-04-16", "2091-04-08", "2092-03-30", "2093-04-12", "2094-04-04", "2095-04-24", "2096-04-15", "2097-03-31", "2098-04-20", "2099-04-12" ]
4
+
5
+ EASTER = {}
6
+
7
+ dates.each do |date|
8
+ easter = Date.parse(date)
9
+ EASTER[easter.year] = easter
10
+ end
11
+
12
+ end
@@ -0,0 +1,82 @@
1
+ module Timetress
2
+ module Holiday
3
+
4
+ JANUARY = 1
5
+ FEBRUARY = 2
6
+ DECEMBER = 12
7
+
8
+ def new_years_day(year)
9
+ Date.new(year, JANUARY, 1)
10
+ end
11
+
12
+ def valentines_day(year)
13
+ Date.new(year, FEBRUARY, 14)
14
+ end
15
+
16
+ def maundy_thursday(year)
17
+ easter_sunday(year) - 3
18
+ end
19
+
20
+ def good_friday(year)
21
+ easter_sunday(year) - 2
22
+ end
23
+
24
+ def easter_sunday(year)
25
+ Timetress::EASTER[year]
26
+ end
27
+
28
+ def easter_monday(year)
29
+ easter_sunday(year) + 1
30
+ end
31
+
32
+ def ascension(year)
33
+ easter_sunday(year) + 39
34
+ end
35
+
36
+ def pentecost_sunday(year)
37
+ easter_sunday(year) + 49
38
+ end
39
+
40
+ def pentecost_monday(year)
41
+ easter_sunday(year) + 50
42
+ end
43
+
44
+ def christmas_eve(year)
45
+ Date.new(year, DECEMBER, 24)
46
+ end
47
+
48
+ def christmas(year)
49
+ Date.new(year, DECEMBER, 25)
50
+ end
51
+
52
+ def boxing_day(year)
53
+ Date.new(year, DECEMBER, 26)
54
+ end
55
+
56
+ def official_holidays(year)
57
+ raise NotImplementedError
58
+ end
59
+
60
+ private
61
+
62
+ def next_holiday(holiday, given_date)
63
+ the_day = self.send(holiday.to_sym, given_date.year)
64
+
65
+ if the_day < given_date
66
+ the_day = self.send(holiday.to_sym, given_date.year + 1)
67
+ end
68
+
69
+ the_day
70
+ end
71
+
72
+ def method_missing(method, *args, &block)
73
+ if method.to_s =~ /^next_(.*)$/
74
+ next_holiday($1, args.first)
75
+ elsif method.to_s =~ /(.*)_for_season/
76
+ holiday_for_season($1, *args)
77
+ else
78
+ super
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,9 @@
1
+ require 'timetress/norway/holiday'
2
+
3
+ module Timetress
4
+ module Norway
5
+ extend Timetress::Norway::Holiday
6
+ extend Timetress::Workday
7
+
8
+ end
9
+ end
@@ -0,0 +1,58 @@
1
+ module Timetress
2
+ module Norway
3
+ module Holiday
4
+ include Timetress::Holiday
5
+
6
+ MAY = 5
7
+ NOVEMBER = 11
8
+
9
+ def mothersday(year)
10
+ second_sunday_in(FEBRUARY, year)
11
+ end
12
+
13
+ def fathersday(year)
14
+ second_sunday_in(NOVEMBER, year)
15
+ end
16
+
17
+ def labour_day(year)
18
+ Date.new(year, MAY, 1)
19
+ end
20
+ alias_method :labor_day, :labour_day
21
+
22
+ def national_holiday(year)
23
+ Date.new(year, MAY, 17)
24
+ end
25
+
26
+ def official_holidays(year)
27
+ [
28
+ new_years_day(year),
29
+ maundy_thursday(year),
30
+ good_friday(year),
31
+ easter_sunday(year),
32
+ easter_monday(year),
33
+ labor_day(year),
34
+ national_holiday(year),
35
+ ascension(year),
36
+ pentecost_sunday(year),
37
+ pentecost_monday(year),
38
+ christmas(year),
39
+ boxing_day(year)
40
+ ]
41
+ end
42
+ alias_method :public_holidays, :official_holidays
43
+ alias_method :legal_holidays, :official_holidays
44
+
45
+ private
46
+ def second_sunday_in(month, year)
47
+ second_week = Date.new(year, month, 8)
48
+ second_week + days_til_sunday(second_week)
49
+ end
50
+
51
+ def days_til_sunday(date)
52
+ (7 - date.wday) % 7
53
+ end
54
+
55
+
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,3 @@
1
+ module Timetress
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,28 @@
1
+ module Timetress
2
+ module Workday
3
+
4
+ def workday?(date)
5
+ !day_off?(date)
6
+ end
7
+
8
+ def day_off?(date)
9
+ [0,6].include?(date.wday) || official_holidays(date.year).include?(date)
10
+ end
11
+
12
+ def nth_workday_after(n, date)
13
+ target = date + n
14
+ until workday?(target)
15
+ target += 1
16
+ end
17
+ target
18
+ end
19
+
20
+ def nth_workday_before(n, date)
21
+ target = date - n
22
+ until workday?(target)
23
+ target -= 1
24
+ end
25
+ target
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,109 @@
1
+ require 'timetress'
2
+
3
+ module Timetress
4
+ module Holiday
5
+ def pi_day(year)
6
+ Date.new(year, 3, 14)
7
+ end
8
+ end
9
+ end
10
+
11
+ describe Timetress::Holiday do
12
+
13
+ describe "New Year's Day" do
14
+ it "is on Jan 1st" do
15
+ Timetress.new_years_day(2011).should eq Date.new(2011, 1, 1)
16
+ end
17
+ end
18
+
19
+ describe "Valentines Day" do
20
+ it "is on Feb 14th" do
21
+ Timetress.valentines_day(2011).should eq Date.new(2011, 2, 14)
22
+ end
23
+ end
24
+
25
+ describe "Maundy Thursday" do
26
+ it "is the Thursday before Easter" do
27
+ Timetress.maundy_thursday(2011).should eq Date.new(2011, 4, 21)
28
+ end
29
+ end
30
+
31
+ describe "Good Friday" do
32
+ it "is the Friday before Easter" do
33
+ Timetress.good_friday(2011).should eq Date.new(2011, 4, 22)
34
+ end
35
+ end
36
+
37
+ describe "Easter Sunday" do
38
+ it "is crazy" do
39
+ Timetress.easter_sunday(2011).should eq Date.new(2011, 4, 24)
40
+ end
41
+ end
42
+
43
+ describe "Easter Monday" do
44
+ it "is the day after Easter Sunday" do
45
+ Timetress.easter_monday(2011).should eq Date.new(2011, 4, 25)
46
+ end
47
+ end
48
+
49
+ describe "Ascension" do
50
+ it "is Thursday, 39 days after Easter" do
51
+ Timetress.ascension(2011).should eq Date.new(2011, 6, 2)
52
+ end
53
+ end
54
+
55
+ describe "Pentecost Sunday" do
56
+ it "is 49 days after Easter" do
57
+ Timetress.pentecost_sunday(2011).should eq Date.new(2011, 6, 12)
58
+ end
59
+ end
60
+
61
+ describe "Pentecost Monday" do
62
+ it "is 50 days after Easter" do
63
+ Timetress.pentecost_monday(2011).should eq Date.new(2011, 6, 13)
64
+ end
65
+ end
66
+
67
+ describe "Christmas Eve" do
68
+ it "is on Dec 24th" do
69
+ Timetress.christmas_eve(2011).should eq Date.new(2011, 12, 24)
70
+ end
71
+ end
72
+
73
+ describe "Christmas" do
74
+ it "is on Dec 25th" do
75
+ Timetress.christmas(2011).should eq Date.new(2011, 12, 25)
76
+ end
77
+ end
78
+
79
+ describe "Boxing Day" do
80
+ it "is on Dec 26th" do
81
+ Timetress.boxing_day(2011).should eq Date.new(2011, 12, 26)
82
+ end
83
+ end
84
+
85
+ describe "official holidays" do
86
+ it "must be implemented in subclass" do
87
+ ->{ Timetress.official_holidays(2012) }.should raise_error
88
+ end
89
+ end
90
+
91
+ describe "next pi day" do
92
+ let(:last_pi_day) { Date.new(2010, 3, 14) }
93
+ let(:pi_day) { Date.new(2011, 3, 14) }
94
+ let(:next_pi_day) { Date.new(2012, 3, 14) }
95
+
96
+ it "is on March 14th" do
97
+ Timetress.next_pi_day(pi_day - 1).should eq(pi_day)
98
+ end
99
+
100
+ it "is this year if today is pi day" do
101
+ Timetress.next_pi_day(pi_day).should eq(pi_day)
102
+ end
103
+
104
+ it "is next year if it's already passed" do
105
+ Timetress.next_pi_day(pi_day + 1).should eq(next_pi_day)
106
+ end
107
+
108
+ end
109
+ end
@@ -0,0 +1,75 @@
1
+ require 'timetress'
2
+
3
+ describe Timetress::Norway do
4
+
5
+ it "has common holidays" do
6
+ Timetress::Norway.new_years_day(2011).should eq Date.new(2011, 1, 1)
7
+ end
8
+
9
+ describe "Mothersday" do
10
+ it "is on the second Sunday of February" do
11
+ Timetress::Norway.mothersday(2011).should eq Date.new(2011, 2, 13)
12
+ end
13
+ end
14
+
15
+ describe "Labour Day" do
16
+ it "is on May 1st" do
17
+ Timetress::Norway.labour_day(2011).should eq Date.new(2011, 5, 1)
18
+ end
19
+
20
+ it "is sometimes spelled without the 'u'" do
21
+ Timetress::Norway.labor_day(2011).should eq Date.new(2011, 5, 1)
22
+ end
23
+ end
24
+
25
+ describe "National holiday" do
26
+ it "is on May 17th" do
27
+ Timetress::Norway.national_holiday(2011).should eq Date.new(2011, 5, 17)
28
+ end
29
+ end
30
+
31
+ describe "Fathersday" do
32
+ it "is on the second Sunday of November" do
33
+ Timetress::Norway.fathersday(2011).should eq Date.new(2011, 11, 13)
34
+ end
35
+ end
36
+
37
+ describe "official holidays" do
38
+ let(:holidays) do
39
+ expected = [
40
+ Date.new(2012, 1, 1),
41
+ Date.new(2012, 4, 5),
42
+ Date.new(2012, 4, 6),
43
+ Date.new(2012, 4, 8),
44
+ Date.new(2012, 4, 9),
45
+ Date.new(2012, 5, 1),
46
+ Date.new(2012, 5, 17),
47
+ Date.new(2012, 5, 17), # The bastards! Cheating us of a day off.
48
+ Date.new(2012, 5, 27),
49
+ Date.new(2012, 5, 28),
50
+ Date.new(2012, 12, 25),
51
+ Date.new(2012, 12, 26)
52
+ ]
53
+ end
54
+
55
+ specify "are known to us" do
56
+ Timetress::Norway.official_holidays(2012).should eq(holidays)
57
+ end
58
+
59
+ specify "are also called public holidays" do
60
+ Timetress::Norway.public_holidays(2012).should eq(holidays)
61
+ end
62
+
63
+ specify "are also called legal holidays" do
64
+ Timetress::Norway.legal_holidays(2012).should eq(holidays)
65
+ end
66
+ end
67
+
68
+ describe "next holiday" do
69
+ it "works" do
70
+ mothersday = Date.new(2011, 2, 13)
71
+ Timetress::Norway.next_mothersday(mothersday - 1).should eq(mothersday)
72
+ end
73
+ end
74
+
75
+ end
@@ -0,0 +1,7 @@
1
+ require 'timetress'
2
+
3
+ describe Timetress::Norway do
4
+ it "responds to workday?" do
5
+ Timetress::Norway.respond_to?(:workday?).should == true
6
+ end
7
+ end
@@ -0,0 +1,87 @@
1
+ require 'timetress'
2
+
3
+ module Somewhere
4
+ extend Timetress::Workday
5
+
6
+ class << self
7
+ def official_holidays(year)
8
+ [Date.new(year, 3, 14)]
9
+ end
10
+ end
11
+ end
12
+
13
+ describe Timetress::Workday do
14
+ describe "#workday?" do
15
+ it "does not coincide with weekends" do
16
+ Somewhere.workday?(Date.new(2012, 9, 29)).should == false
17
+ Somewhere.workday?(Date.new(2012, 9, 30)).should == false
18
+ end
19
+
20
+ it "does not fall on holidays" do
21
+ Somewhere.workday?(Date.new(2012, 3, 14)).should == false
22
+ end
23
+
24
+ it "is just a regular, hum-drum day" do
25
+ (1..5).each do |i|
26
+ Somewhere.workday?(Date.new(2012, 10, i)).should == true
27
+ end
28
+ end
29
+ end
30
+
31
+ describe "#day_off?" do
32
+ specify "Yes, if it is the weekend." do
33
+ Somewhere.day_off?(Date.new(2012, 9, 29)).should == true
34
+ Somewhere.day_off?(Date.new(2012, 9, 30)).should == true
35
+ end
36
+
37
+ specify "Certainly, when celebrating holidays." do
38
+ Somewhere.day_off?(Date.new(2012, 3, 14)).should == true
39
+ end
40
+
41
+ specify "Not during the week, usually" do
42
+ (1..5).each do |i|
43
+ Somewhere.day_off?(Date.new(2012, 10, i)).should == false
44
+ end
45
+ end
46
+ end
47
+
48
+ describe "#nth_workday_before" do
49
+ let(:wednesday) { Date.new(2011, 2, 9) }
50
+ let(:friday) { Date.new(2011, 2, 11) }
51
+ let(:sunday) { Date.new(2011, 2, 13) }
52
+ let(:monday) { Date.new(2011, 2, 14) }
53
+
54
+ it "works within the same week" do
55
+ Somewhere.nth_workday_before(2, friday).should == wednesday
56
+ end
57
+
58
+ it "spans weekends successfully" do
59
+ Somewhere.nth_workday_before(1, monday).should == friday
60
+ end
61
+
62
+ it "works within a weekend" do
63
+ Somewhere.nth_workday_before(4, sunday).should == wednesday
64
+ end
65
+ end
66
+
67
+ describe "#nth_workday_after" do
68
+ let(:wednesday) { Date.new(2011, 2, 9) }
69
+ let(:friday) { Date.new(2011, 2, 11) }
70
+ let(:saturday) { Date.new(2011, 2, 12) }
71
+ let(:monday) { Date.new(2011, 2, 14) }
72
+
73
+ it "works within the same week" do
74
+ Somewhere.nth_workday_after(2, wednesday).should == friday
75
+ end
76
+
77
+ it "spans weekends correctly" do
78
+ Somewhere.nth_workday_after(3, wednesday).should == monday
79
+ end
80
+
81
+ it "works within a weekend" do
82
+ Somewhere.nth_workday_after(1, saturday).should == monday
83
+ end
84
+ end
85
+
86
+ end
87
+
data/timetress.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'timetress/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "timetress"
8
+ gem.version = Timetress::VERSION
9
+ gem.authors = ["Katrina Owen"]
10
+ gem.email = ["katrina.owen@gmail.com"]
11
+ gem.description = %q{Answers the age-old question 'When is mothersday this year?'}
12
+ gem.summary = %q{Knows about holidays and workdays}
13
+ gem.homepage = "https://github.com/kytrinyx/timetress"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timetress
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Katrina Owen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-26 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Answers the age-old question 'When is mothersday this year?'
15
+ email:
16
+ - katrina.owen@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/timetress.rb
27
+ - lib/timetress/easter.rb
28
+ - lib/timetress/holiday.rb
29
+ - lib/timetress/norway.rb
30
+ - lib/timetress/norway/holiday.rb
31
+ - lib/timetress/version.rb
32
+ - lib/timetress/workday.rb
33
+ - spec/holiday_spec.rb
34
+ - spec/norway/holiday_spec.rb
35
+ - spec/norway/workday_spec.rb
36
+ - spec/workday_spec.rb
37
+ - timetress.gemspec
38
+ homepage: https://github.com/kytrinyx/timetress
39
+ licenses: []
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 1.8.15
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Knows about holidays and workdays
62
+ test_files:
63
+ - spec/holiday_spec.rb
64
+ - spec/norway/holiday_spec.rb
65
+ - spec/norway/workday_spec.rb
66
+ - spec/workday_spec.rb