joerichsen-danske_helligdage 1.0.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.
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ === 1.0.0 / 2008-10-24
2
+
3
+ * First release
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/danske_helligdage
6
+ lib/danske_helligdage.rb
7
+ test/test_danske_helligdage.rb
data/README.txt ADDED
@@ -0,0 +1,72 @@
1
+ = DanskeHelligdage
2
+
3
+ * http://github.com/joerichsen/danske_helligdage/
4
+
5
+ == DESCRIPTION:
6
+
7
+ Add support for public holidays in Denmark in the Date class
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ Uses the list of public holidays in Denmark found in
12
+ https://www.borger.dk/Emner/samfundogrettigheder/kirkeogtro/Sider/officiellehelligedage.aspx
13
+
14
+ == SYNOPSIS:
15
+
16
+ Require it
17
+ require 'danske_helligdage'
18
+
19
+ Get the name of a public holiday
20
+ Date.civil(2008, 12, 25).helligdag returns 'Juledag'
21
+
22
+ Ask whether a date is a public holiday
23
+ Date.civil(2008, 12, 25).helligdag? returns true
24
+
25
+ Ask whether a date is a working day
26
+ Date.civil(2008, 12, 25).arbejdsdag? returns false
27
+
28
+ Get the number of working days for a given month
29
+ Date.arbejdsdage(2008, 1) returns 22
30
+
31
+ Or for a specific period
32
+ Date.arbejdsdage_i_periode(Date.civil(2008, 1, 1), Date.civil(2008, 12, 31)) returns 252
33
+
34
+ Note that 1. maj, grundlovsdag and juleaftensdag are not official Danish public holidays,
35
+ so to enable them you do something like this
36
+ require 'danske_helligdage'
37
+ require 'danske_helligdage/juleaftensdag'
38
+
39
+ Then all of the methods above will take juleaftensdag into consideration.
40
+
41
+ == REQUIREMENTS:
42
+
43
+ * None
44
+
45
+ == INSTALL:
46
+
47
+ * sudo gem install danske_helligdage
48
+
49
+ == LICENSE:
50
+
51
+ (The MIT License)
52
+
53
+ Copyright (c) 2008 Jørgen Orehøj Erichsen
54
+
55
+ Permission is hereby granted, free of charge, to any person obtaining
56
+ a copy of this software and associated documentation files (the
57
+ 'Software'), to deal in the Software without restriction, including
58
+ without limitation the rights to use, copy, modify, merge, publish,
59
+ distribute, sublicense, and/or sell copies of the Software, and to
60
+ permit persons to whom the Software is furnished to do so, subject to
61
+ the following conditions:
62
+
63
+ The above copyright notice and this permission notice shall be
64
+ included in all copies or substantial portions of the Software.
65
+
66
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
67
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
68
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
69
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
70
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
71
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
72
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ $:.unshift(File.dirname(__FILE__) + "/lib")
6
+ require 'danske_helligdage'
7
+
8
+ Hoe.new('DanskeHelligdage', DanskeHelligdage::VERSION) do |p|
9
+ p.developer('Jørgen Orehøj Erichsen', 'joe@erichsen.net')
10
+ end
11
+
12
+ # vim: syntax=Ruby
@@ -0,0 +1,4 @@
1
+ require 'date'
2
+ require 'danske_helligdage/officielle'
3
+
4
+ Date.send(:include, DanskeHelligdage::Officielle)
@@ -0,0 +1,62 @@
1
+ require 'danske_helligdage'
2
+
3
+ class DanskeHelligdageTests < Test::Unit::TestCase
4
+
5
+ def test_should_return_the_name_of_the_holiday
6
+ assert_equal 'Nytårsdag', Date.civil(2008, 1, 1).helligdag
7
+ assert_equal 'Skærtorsdag', Date.civil(2008, 3, 20).helligdag
8
+ assert_equal 'Langfredag', Date.civil(2008, 3, 21).helligdag
9
+ assert_equal 'Påskedag', Date.civil(2008, 3, 23).helligdag
10
+ assert_equal '2. påskedag', Date.civil(2008, 3, 24).helligdag
11
+ assert_equal 'Store Bededag', Date.civil(2008, 4, 18).helligdag
12
+ assert_equal 'Kristi himmelfartsdag', Date.civil(2008, 5, 1).helligdag
13
+ assert_equal 'Pinsedag', Date.civil(2008, 5, 11).helligdag
14
+ assert_equal '2. pinsedag', Date.civil(2008, 5, 12).helligdag
15
+ assert_equal '1. juledag', Date.civil(2008, 12, 25).helligdag
16
+ assert_equal '2. juledag', Date.civil(2008, 12, 26).helligdag
17
+ end
18
+
19
+ def test_should_return_nil_for_non_holidays
20
+ assert_nil Date.civil(2008, 1, 2).helligdag
21
+ end
22
+
23
+ def test_should_return_whether_it_is_a_holiday_or_not
24
+ assert Date.civil(2008, 1, 1).helligdag?
25
+ assert Date.civil(2008, 3, 20).helligdag?
26
+ assert Date.civil(2008, 3, 21).helligdag?
27
+ assert Date.civil(2008, 3, 23).helligdag?
28
+ assert Date.civil(2008, 3, 24).helligdag?
29
+ assert Date.civil(2008, 4, 18).helligdag?
30
+ assert Date.civil(2008, 5, 1).helligdag?
31
+ assert Date.civil(2008, 5, 11).helligdag?
32
+ assert Date.civil(2008, 5, 12).helligdag?
33
+ assert Date.civil(2008, 12, 25).helligdag?
34
+ assert Date.civil(2008, 12, 26).helligdag?
35
+ assert !Date.civil(2008, 1, 2).helligdag?
36
+ end
37
+
38
+ def test_should_return_whether_is_is_a_weekend_or_not
39
+ assert !Date.civil(2008, 10, 24).weekend?
40
+ assert Date.civil(2008, 10, 25).weekend?
41
+ assert Date.civil(2008, 10, 26).weekend?
42
+ assert !Date.civil(2008, 10, 27).weekend?
43
+ end
44
+
45
+ def test_should_return_whether_it_is_a_working_day_or_not
46
+ assert Date.civil(2008, 10, 24).arbejdsdag?
47
+ assert !Date.civil(2008, 10, 25).arbejdsdag?
48
+ assert !Date.civil(2008, 10, 26).arbejdsdag?
49
+ assert Date.civil(2008, 10, 27).arbejdsdag?
50
+ assert !Date.civil(2008, 12, 26).arbejdsdag?
51
+ assert !Date.civil(2008, 12, 27).arbejdsdag?
52
+ end
53
+
54
+ def test_should_return_the_number_of_working_days_for_a_given_month
55
+ assert_equal 22, Date.arbejdsdage(2008, 1)
56
+ end
57
+
58
+ def test_should_return_the_number_of_working_days_for_a_given_period
59
+ assert_equal 253, Date.arbejdsdage_i_periode(Date.civil(2008, 1, 1), Date.civil(2008, 12, 31))
60
+ end
61
+
62
+ end
@@ -0,0 +1,18 @@
1
+ require 'danske_helligdage'
2
+
3
+ class FoersteMajTests < Test::Unit::TestCase
4
+
5
+ def setup
6
+ require 'danske_helligdage/foerste_maj'
7
+ end
8
+
9
+ def teardown
10
+ # Restore the original Date class
11
+ Date.send(:include, DanskeHelligdage::Officielle)
12
+ end
13
+
14
+ def test_should_return_the_name_of_the_holiday
15
+ assert_equal '1. maj', Date.civil(2008, 5, 1).helligdag
16
+ end
17
+
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'danske_helligdage'
2
+
3
+ class GrundlovsdagTests < Test::Unit::TestCase
4
+
5
+ def setup
6
+ require 'danske_helligdage/grundlovsdag'
7
+ end
8
+
9
+ def teardown
10
+ # Restore the original Date class
11
+ Date.send(:include, DanskeHelligdage::Officielle)
12
+ end
13
+
14
+ def test_should_return_the_name_of_the_holiday
15
+ assert_equal 'Grundlovsdag', Date.civil(2008, 6, 5).helligdag
16
+ end
17
+
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'danske_helligdage'
2
+
3
+ class JuleaftensdagTests < Test::Unit::TestCase
4
+
5
+ def setup
6
+ require 'danske_helligdage/juleaftensdag'
7
+ end
8
+
9
+ def teardown
10
+ # Restore the original Date class
11
+ Date.send(:include, DanskeHelligdage::Officielle)
12
+ end
13
+
14
+ def test_should_return_the_name_of_the_holiday
15
+ assert_equal 'Juleaftensdag', Date.civil(2008, 12, 24).helligdag
16
+ end
17
+
18
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: joerichsen-danske_helligdage
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - "J\xC3\xB8rgen Oreh\xC3\xB8j Erichsen"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-24 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.8.1
23
+ version:
24
+ description: Add support for public holidays in Denmark in the Date class
25
+ email:
26
+ - joe@erichsen.net
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ files:
36
+ - History.txt
37
+ - Manifest.txt
38
+ - README.txt
39
+ - Rakefile
40
+ - bin/danske_helligdage
41
+ - lib/danske_helligdage.rb
42
+ - test/test_danske_helligdage.rb
43
+ - test/test_foerste_maj.rb
44
+ - test/test_grundlovsdag.rb
45
+ - test/test_juleaftensdag.rb
46
+ has_rdoc: true
47
+ homepage: http://github.com/joerichsen/danske_helligdage/
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --main
51
+ - README.txt
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project: danskehelligdage
69
+ rubygems_version: 1.2.0
70
+ signing_key:
71
+ specification_version: 2
72
+ summary: Add support for public holidays in Denmark in the Date class
73
+ test_files:
74
+ - test/test_danske_helligdage.rb