business_time-de 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +26 -0
- data/Rakefile +9 -0
- data/business_time-de.gemspec +29 -0
- data/lib/business_time-de/version.rb +5 -0
- data/lib/business_time-de.rb +18 -0
- data/test_suite.rb +26 -0
- metadata +99 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Christoph Olszowka, Capita Unternehmensberatung GmbH
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Business Time for Germany
|
2
|
+
|
3
|
+
The [business_time](https://github.com/bokmann/business_time) brings business time & days calculations to ActiveSupport.
|
4
|
+
|
5
|
+
This gem pre-configures it for all german holidays, both fixed (Neujahr, Tag der Arbeit, Tag der Deutschen Einheit, Weihnachten)
|
6
|
+
and moving (Easter & it's friends Pfingsten and Himmelfahrt). The easter date is calculated using the
|
7
|
+
[date_easter](https://rubygems.org/gems/date_easter) gem, Pfingsten & Himmelfahrt are calculated based on that,
|
8
|
+
so no hard-coded values here.
|
9
|
+
|
10
|
+
The holidays are defined for `(2000..2099)`, which should be sufficient.
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
gem install business_time-de
|
15
|
+
# OR
|
16
|
+
gem 'business_time-de'
|
17
|
+
|
18
|
+
require 'business_time-de'
|
19
|
+
7.business_days.after(Date.parse("2012-03-28")) # => "2012-04-10" (because of easter)
|
20
|
+
|
21
|
+
For more information on the usage of the [business_time](https://github.com/bokmann/business_time) gem please
|
22
|
+
check out it's documentation.
|
23
|
+
|
24
|
+
## License
|
25
|
+
|
26
|
+
Copyright (c) 2012 Christoph Olszowka, Capita Unternehmensberatung GmbH. Released under MIT License, see LICENSE for more details.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "business_time-de/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "business_time-de"
|
7
|
+
s.version = BusinessTime::De::VERSION
|
8
|
+
s.authors = ["Christoph Olszowka"]
|
9
|
+
s.email = ["christoph at olszowka de"]
|
10
|
+
s.homepage = "https://github.com/capita/business_time-de"
|
11
|
+
s.summary = %q{Pre-configures business_time gem for german holidays from 2000 until 2099}
|
12
|
+
s.description = s.summary
|
13
|
+
|
14
|
+
s.rubyforge_project = "business_time-de"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency "date_easter"
|
22
|
+
s.add_runtime_dependency "business_time"
|
23
|
+
s.add_runtime_dependency "activesupport"
|
24
|
+
|
25
|
+
s.add_development_dependency "testrocket"
|
26
|
+
# specify any dependencies here; for example:
|
27
|
+
# s.add_development_dependency "rspec"
|
28
|
+
# s.add_runtime_dependency "rest-client"
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "business_time-de/version"
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
require 'business_time'
|
4
|
+
require 'date_easter'
|
5
|
+
|
6
|
+
(2000..2099).each do |year|
|
7
|
+
easter_sunday = Date.easter(year)
|
8
|
+
BusinessTime::Config.holidays << easter_sunday # Ostersonntag
|
9
|
+
BusinessTime::Config.holidays << (easter_sunday - 2.days) # Karfreitag
|
10
|
+
BusinessTime::Config.holidays << (easter_sunday + 1.day) # Ostermontag
|
11
|
+
BusinessTime::Config.holidays << (easter_sunday + 39.days) # Christi Himmelfahrt
|
12
|
+
BusinessTime::Config.holidays << (easter_sunday + 50.days) # Pfingstmontag
|
13
|
+
BusinessTime::Config.holidays << Time.mktime(year, 1, 1).to_date # Neujahr
|
14
|
+
BusinessTime::Config.holidays << Time.mktime(year, 5, 1).to_date # Tag der Arbeit
|
15
|
+
BusinessTime::Config.holidays << Time.mktime(year, 10, 3).to_date # Tag der deutschen Einheit
|
16
|
+
BusinessTime::Config.holidays << Time.mktime(year, 12, 25).to_date # Weihnachten
|
17
|
+
BusinessTime::Config.holidays << Time.mktime(year, 12, 26).to_date # Weihnachten
|
18
|
+
end
|
data/test_suite.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'testrocket'
|
2
|
+
require 'business_time-de'
|
3
|
+
|
4
|
+
+-> { 7.business_days.after(Date.parse("2012-03-28")).to_date == Date.parse("2012-04-10") }
|
5
|
+
+-> { Date.parse("2012-04-10").workday? }
|
6
|
+
--> { Date.parse("2012-04-09").workday? }
|
7
|
+
|
8
|
+
(2000..2099).each do |year|
|
9
|
+
--> { Date.parse("#{year}-01-01").workday? }
|
10
|
+
--> { Date.parse("#{year}-05-01").workday? }
|
11
|
+
--> { Date.parse("#{year}-10-03").workday? }
|
12
|
+
--> { Date.parse("#{year}-12-25").workday? }
|
13
|
+
--> { Date.parse("#{year}-12-26").workday? }
|
14
|
+
end
|
15
|
+
|
16
|
+
# Ultimate easter date list, nicked from http://www.assa.org.au/edm.html
|
17
|
+
["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"].each do |d|
|
18
|
+
easter = Date.parse(d)
|
19
|
+
--> { (easter + 1.day).workday? } # Ostermontag
|
20
|
+
--> { (easter - 1.day).workday? } # Saturday
|
21
|
+
--> { (easter - 2.days).workday? } # Karfreitag
|
22
|
+
|
23
|
+
+-> { (easter - 3.days).workday? } # Gründonnerstag
|
24
|
+
# The next business day after gründonnerstag is tuesday...
|
25
|
+
+-> { 1.business_day.after(easter - 3.days).to_date == (easter+2.days).to_date }
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: business_time-de
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Christoph Olszowka
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: date_easter
|
16
|
+
requirement: &20656960 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *20656960
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: business_time
|
27
|
+
requirement: &20656200 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *20656200
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activesupport
|
38
|
+
requirement: &20655620 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *20655620
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: testrocket
|
49
|
+
requirement: &20654980 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *20654980
|
58
|
+
description: Pre-configures business_time gem for german holidays from 2000 until
|
59
|
+
2099
|
60
|
+
email:
|
61
|
+
- christoph at olszowka de
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- .gitignore
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- business_time-de.gemspec
|
72
|
+
- lib/business_time-de.rb
|
73
|
+
- lib/business_time-de/version.rb
|
74
|
+
- test_suite.rb
|
75
|
+
homepage: https://github.com/capita/business_time-de
|
76
|
+
licenses: []
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project: business_time-de
|
95
|
+
rubygems_version: 1.8.17
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: Pre-configures business_time gem for german holidays from 2000 until 2099
|
99
|
+
test_files: []
|