arbeitszeitkonto 0.5.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.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +4 -0
- data/Gemfile +5 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/arbeitszeitkonto.gemspec +34 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/arbeitszeitkonto/feiertag_zeitkonto_calculator.rb +38 -0
- data/lib/arbeitszeitkonto/taeglich_zeitkonto_calculator.rb +35 -0
- data/lib/arbeitszeitkonto/version.rb +3 -0
- data/lib/arbeitszeitkonto/woechentlich_zeitkonto_calculator.rb +62 -0
- data/lib/arbeitszeitkonto/zeitkonto_calculator.rb +41 -0
- data/lib/arbeitszeitkonto/zeitspanne.rb +116 -0
- data/lib/arbeitszeitkonto.rb +13 -0
- data/sandbox/time_manipulation.rb +35 -0
- metadata +102 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: fd0818b871b0e3d470536a15ea1f490d1ade255c
|
|
4
|
+
data.tar.gz: 00609473385424125a12fefb5b7361bef0aad76c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b54984d5489c0acd3a4a3f91970aa80f7a0021fc4cdbbefab5cb5588040583d82a6fa4bd3405418326ed306b144fbc71f9ea6fd40fb41454b99e08ca476a4382
|
|
7
|
+
data.tar.gz: 2bda86232f966449026622cbd84d15d13e4897d73dad41fc02e909082ef52d979f7dd84699001c971a530c34d6a2e270ecd2b967fd754e79f048b64c3a66af58
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Arbeitszeitkonto
|
|
2
|
+
Berechnet die Zetien einer Zeitspanne für die einzelnen Zeitkonti.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Versionen
|
|
6
|
+
### 0.5.0 27. August 2015
|
|
7
|
+
* Initialversion, für die Bedürfnisse von ATG erstellt
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## gem erstellen und auf rubygems raufladen
|
|
11
|
+
gem build arbeitszeitkonto.gemspec
|
|
12
|
+
gem push arbeitszeitkonto-x.x.x.gem
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
Add this line to your application's Gemfile:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
gem 'arbeitszeitkonto'
|
|
19
|
+
```
|
|
20
|
+
And then execute:
|
|
21
|
+
|
|
22
|
+
$ bundle
|
|
23
|
+
|
|
24
|
+
Or install it yourself as:
|
|
25
|
+
|
|
26
|
+
$ gem install arbeitszeitkonto
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
31
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'arbeitszeitkonto/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "arbeitszeitkonto"
|
|
8
|
+
spec.version = Arbeitszeitkonto::VERSION
|
|
9
|
+
spec.authors = ["Christian Mühlethaler"]
|
|
10
|
+
spec.email = ["christian.muehlethaler@optor.ch"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Berechnet die Zeiten für die verschiedenen Zeitkonti}
|
|
13
|
+
#spec.description = %q{Berechnet die Zeiten für die verschiedenen Zeitkonti}
|
|
14
|
+
spec.homepage = "http://www.planik.ch"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
|
19
|
+
# if spec.respond_to?(:metadata)
|
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
+
# else
|
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.3"
|
|
33
|
+
|
|
34
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "arbeitszeitkonto"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Arbeitszeitkonto
|
|
2
|
+
##
|
|
3
|
+
# Feiertag
|
|
4
|
+
##
|
|
5
|
+
class FeiertagZeitkontoCalculator < ZeitkontoCalculator
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
# @feiertage: Array von Dates
|
|
10
|
+
# @zeit_von, @zeit_bis: Times für die Zeitangaben
|
|
11
|
+
# @start_tag: Wann die Feiertagzeitspanne beginnt. Es kann ja sein, dass sie am Tag vorher beginnt
|
|
12
|
+
##
|
|
13
|
+
def initialize feiertage, zeit_von, zeit_bis, start_tag = 0
|
|
14
|
+
@feiertage_zeitspannen = create_feiertage_zeitspannen(feiertage, zeit_von, zeit_bis, start_tag)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def calculate zeitspannen
|
|
20
|
+
calc(Array(zeitspannen), @feiertage_zeitspannen)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
##
|
|
27
|
+
# Erstellt für jeden Feiertag eine Zeitspanne
|
|
28
|
+
##
|
|
29
|
+
def create_feiertage_zeitspannen feiertage, zeit_von, zeit_bis, start_tag
|
|
30
|
+
anzahl_tage_dazwischen = (zeit_bis.to_date - zeit_von.to_date).to_i
|
|
31
|
+
feiertage.map do |f|
|
|
32
|
+
f = f + start_tag.days
|
|
33
|
+
Zeitspanne.new(kombiniere(f, zeit_von), kombiniere(f, zeit_bis)+anzahl_tage_dazwischen.days)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Arbeitszeitkonto
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Ein Zeitkonto im Rhythmus :täglich
|
|
5
|
+
##
|
|
6
|
+
class TaeglichZeitkontoCalculator < ZeitkontoCalculator
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
#
|
|
10
|
+
#
|
|
11
|
+
def initialize zeit_von, zeit_bis
|
|
12
|
+
@zeit_von = zeit_von
|
|
13
|
+
@zeit_bis = zeit_bis
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
##
|
|
18
|
+
# Liefert
|
|
19
|
+
# * Anzahl Sekunden, welche die gegebene :zeitspanne mit dem Zeitkonto überlappt
|
|
20
|
+
# * Die Reste (Zeitspanne[n])
|
|
21
|
+
##
|
|
22
|
+
def calculate zeitspannen
|
|
23
|
+
reste = []
|
|
24
|
+
seconds = 0
|
|
25
|
+
Array(zeitspannen).each do |zeitspanne|
|
|
26
|
+
zeitspanne_1 = Zeitspanne.relative(zeitspanne.datum - 1, @zeit_von, @zeit_bis)
|
|
27
|
+
zeitspanne_2 = Zeitspanne.relative(zeitspanne.datum, @zeit_von, @zeit_bis)
|
|
28
|
+
sec, r = calc(Array(zeitspanne), [zeitspanne_1, zeitspanne_2])
|
|
29
|
+
seconds+=sec
|
|
30
|
+
reste.push(*r)
|
|
31
|
+
end
|
|
32
|
+
[seconds, reste]
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module Arbeitszeitkonto
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Ein Zeitkonto im Rhythmus :wöchentlich
|
|
5
|
+
##
|
|
6
|
+
class WoechentlichZeitkontoCalculator < ZeitkontoCalculator
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
# @wday: Wochentag, an dem die Zeitspanne beginnt: 0 = Sonntag, 6 = Samstag
|
|
10
|
+
# @zeit_von und @zeit_bis: zwei Times, die die Zeit und die Länge zwischen @zeit_von und @zeit_bis definieren
|
|
11
|
+
##
|
|
12
|
+
def initialize wday, zeit_von, zeit_bis
|
|
13
|
+
@wday = wday
|
|
14
|
+
@zeit_von = zeit_von
|
|
15
|
+
@zeit_bis = zeit_bis
|
|
16
|
+
@anzahl_tage_dazwischen = (@zeit_bis.to_date - @zeit_von.to_date).to_i
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
# Liefert
|
|
22
|
+
# * Anzahl Sekunden, welche die gegebene :zeitspanne mit dem Zeitkonto überlappt
|
|
23
|
+
# * Die Reste (Zeitspanne[n])
|
|
24
|
+
##
|
|
25
|
+
def calculate zeitspannen
|
|
26
|
+
reste = []
|
|
27
|
+
seconds = 0
|
|
28
|
+
|
|
29
|
+
Array(zeitspannen).each do |zeitspanne|
|
|
30
|
+
|
|
31
|
+
anzahl_tage_zurueck = calculate_tage_zurueck(zeitspanne.datum_zeit_von.wday, @wday)
|
|
32
|
+
|
|
33
|
+
datum = zeitspanne.datum_zeit_von - anzahl_tage_zurueck.days
|
|
34
|
+
datum_zeit_von = kombiniere(datum, @zeit_von)
|
|
35
|
+
datum_zeit_bis = kombiniere(datum, @zeit_bis) + @anzahl_tage_dazwischen.days
|
|
36
|
+
|
|
37
|
+
zeitkonto_zeitspanne_eins = Zeitspanne.new(datum_zeit_von, datum_zeit_bis)
|
|
38
|
+
zeitkonto_zeitspanne_zwei = Zeitspanne.new(datum_zeit_von+7.days, datum_zeit_bis+7.days)
|
|
39
|
+
|
|
40
|
+
#puts "#{self.class.name}#calculate: wday der ersten Zeitspanne: #{zeitkonto_zeitspanne_eins.datum_zeit_von.wday}"
|
|
41
|
+
#puts "#{self.class.name}#calculate: wday der zweiten Zeitspanne: #{zeitkonto_zeitspanne_zwei.datum_zeit_von.wday}"
|
|
42
|
+
|
|
43
|
+
raise ArbeitszeitkontoError, "wday ist entspricht nicht wday der Vorlage " if @wday != zeitkonto_zeitspanne_eins.datum_zeit_von.wday || @wday != zeitkonto_zeitspanne_zwei.datum_zeit_von.wday
|
|
44
|
+
sec, r = calc([zeitspanne], [zeitkonto_zeitspanne_eins, zeitkonto_zeitspanne_zwei])
|
|
45
|
+
seconds+=sec
|
|
46
|
+
reste.push(*r)
|
|
47
|
+
end
|
|
48
|
+
[seconds, reste]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
#
|
|
54
|
+
# Berechnet die Anzahl Tage
|
|
55
|
+
#
|
|
56
|
+
def calculate_tage_zurueck(wday_kandidat, wday_calculator)
|
|
57
|
+
anzahl_tage_zurueck = (wday_kandidat - wday_calculator) % 7
|
|
58
|
+
#puts "#{self.class.name}#calculate: Zeitspanne: wday Kandidat = #{wday_kandidat}, wday Calculator: #{wday_calculator}, anzahl_tage_zurueck: #{anzahl_tage_zurueck}"
|
|
59
|
+
anzahl_tage_zurueck
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Arbeitszeitkonto
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Zulagen berechnen für Medphone
|
|
5
|
+
##
|
|
6
|
+
class ZeitkontoCalculator
|
|
7
|
+
|
|
8
|
+
protected
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# Erstellt ein neues Time Objekt mit Datum von @datum und dem Reste von @zeit
|
|
13
|
+
##
|
|
14
|
+
def kombiniere(datum, zeit)
|
|
15
|
+
zeit.change(year: datum.year, month: datum.month, day: datum.day)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
# Hilfsfunktion, um die Zeiten für die Zulagen zu berechnen
|
|
20
|
+
# liefert die Anzahl Sekunde der Überlappung(en) und den Rest als Zeitspanne zurück
|
|
21
|
+
##
|
|
22
|
+
def calc zeitspannen, zeitspannen_des_zeitkontos
|
|
23
|
+
sum_seconds = 0
|
|
24
|
+
zeitspannen_des_zeitkontos.each do |zeitspanne_des_kontos|
|
|
25
|
+
neue_zeitspannen = []
|
|
26
|
+
zeitspannen.each do |zeitspanne|
|
|
27
|
+
|
|
28
|
+
#puts "#{self.class.name}#calc: kandidat_zeitspanne = #{zeitspanne.to_s}"
|
|
29
|
+
#puts "#{self.class.name}#calc: zeitspanne_des_kontos = #{zeitspanne_des_kontos.to_s}"
|
|
30
|
+
seconds, reste = zeitspanne_des_kontos.overlap(zeitspanne)
|
|
31
|
+
neue_zeitspannen.push(*reste)
|
|
32
|
+
sum_seconds += seconds
|
|
33
|
+
end
|
|
34
|
+
zeitspannen = neue_zeitspannen
|
|
35
|
+
end
|
|
36
|
+
#puts "#{self.class.name}#calc: Reste = #{zeitspannen.map(&:to_s).join(", ")}"
|
|
37
|
+
[sum_seconds, zeitspannen]
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
module Arbeitszeitkonto
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Definiert eine Zeitspanne einer bestimmten Zeitkontos (Sa, den 03.08.15 von 22 - 24) oder eines Dienstes.
|
|
5
|
+
# Kann die Ueberlappung von zwei Zeitspannen berechnen
|
|
6
|
+
##
|
|
7
|
+
class Zeitspanne
|
|
8
|
+
attr_reader :datum_zeit_von, :datum_zeit_bis
|
|
9
|
+
|
|
10
|
+
#def self.from_dienst dienst
|
|
11
|
+
# Zeitspanne.new(dienst.datum_zeit_von.to_date, dienst.datum_zeit_von, dienst.datum_zeit_bis, from_dienst: true)
|
|
12
|
+
#end
|
|
13
|
+
|
|
14
|
+
def self.relative datum, zeit_von, zeit_bis
|
|
15
|
+
self.new(create_time(datum, zeit_von), create_time(datum, zeit_bis, zeit_von[0] > zeit_bis[0]))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
# Hilfsfunktion um ein Timeobjekt zu erzeugen
|
|
20
|
+
def self.create_time(datum, zeit, next_day = false)
|
|
21
|
+
datum = datum +1 if next_day
|
|
22
|
+
Time.new(datum.year, datum.month, datum.day, zeit[0], zeit[1])
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def initialize(zeit_von, zeit_bis)
|
|
27
|
+
raise(ArbeitszeitkontoError, "zeit_von ist grösser als zeit_bis") if zeit_von > zeit_bis
|
|
28
|
+
raise(ArbeitszeitkontoError, "zeit_von und zeit_bis sind gleich") if zeit_von == zeit_bis
|
|
29
|
+
@datum_zeit_von = zeit_von
|
|
30
|
+
@datum_zeit_bis = zeit_bis
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def datum
|
|
34
|
+
datum_zeit_von.to_date
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# liefert die Überlappung der beiden Zeitspannen in Sekunden
|
|
39
|
+
#
|
|
40
|
+
#
|
|
41
|
+
# Fall 1: komplette Überlappung
|
|
42
|
+
# ========================
|
|
43
|
+
# kandidat : |-----|
|
|
44
|
+
# self : |---------|
|
|
45
|
+
|
|
46
|
+
# Fall 2: Teilweise Überlappung
|
|
47
|
+
# ========================
|
|
48
|
+
# kandidat : |-----|
|
|
49
|
+
# self : |---------|
|
|
50
|
+
#------------------------------
|
|
51
|
+
# kandidat : |-----|
|
|
52
|
+
# self : |---------|
|
|
53
|
+
#
|
|
54
|
+
#------------------------------
|
|
55
|
+
# kandidat : |----------|
|
|
56
|
+
# self : |-----|
|
|
57
|
+
#
|
|
58
|
+
# Fall 3 Keine überlappung
|
|
59
|
+
# ========================
|
|
60
|
+
# kandidat : |-----|
|
|
61
|
+
# self : |---------|
|
|
62
|
+
#------------------------------
|
|
63
|
+
# kandidat : |-----|
|
|
64
|
+
# self : |--------|
|
|
65
|
+
#
|
|
66
|
+
|
|
67
|
+
##
|
|
68
|
+
def overlap(kandidat)
|
|
69
|
+
seconds = 0
|
|
70
|
+
reste = []
|
|
71
|
+
case
|
|
72
|
+
# Fall 1: komplette Überlappung
|
|
73
|
+
when kandidat.datum_zeit_von >= datum_zeit_von && kandidat.datum_zeit_bis <= datum_zeit_bis
|
|
74
|
+
#puts "#{self.class.name}#overlap: komplette Überlappung"
|
|
75
|
+
seconds = kandidat.datum_zeit_bis - kandidat.datum_zeit_von
|
|
76
|
+
# rest3: keine
|
|
77
|
+
# Fall 2a: Teilüberlappung
|
|
78
|
+
when kandidat.datum_zeit_von < datum_zeit_von && kandidat.datum_zeit_bis > datum_zeit_von && kandidat.datum_zeit_bis <= datum_zeit_bis
|
|
79
|
+
#puts "#{self.class.name}#overlap: Teilweise Überlappung: vorne"
|
|
80
|
+
seconds = kandidat.datum_zeit_bis - datum_zeit_von
|
|
81
|
+
reste << Zeitspanne.new(kandidat.datum_zeit_von, datum_zeit_von)
|
|
82
|
+
# rest: kandidat.datum_zeit_von - self.datzm_zeit_von
|
|
83
|
+
# Fall 2b: Teilüberlappung
|
|
84
|
+
when kandidat.datum_zeit_von > datum_zeit_von && kandidat.datum_zeit_von < datum_zeit_bis
|
|
85
|
+
#puts "#{self.class.name}#overlap: Teilweise Überlappung: hinten"
|
|
86
|
+
seconds = datum_zeit_bis - kandidat.datum_zeit_von
|
|
87
|
+
reste << Zeitspanne.new(datum_zeit_bis, kandidat.datum_zeit_bis)
|
|
88
|
+
# Fall 2c: Teilüberlappung: Kandidat lappt über beide Ende
|
|
89
|
+
when kandidat.datum_zeit_von < datum_zeit_von && kandidat.datum_zeit_bis > datum_zeit_bis
|
|
90
|
+
#puts "#{self.class.name}#overlap: Fall 2c: Teilüberlappung: Kandidat lappt über beide Ende "
|
|
91
|
+
seconds = datum_zeit_bis - datum_zeit_von
|
|
92
|
+
reste << Zeitspanne.new(kandidat.datum_zeit_von, datum_zeit_von)
|
|
93
|
+
reste << Zeitspanne.new(datum_zeit_bis, kandidat.datum_zeit_bis)
|
|
94
|
+
# Fall 3: Keine Überlappung
|
|
95
|
+
when kandidat.datum_zeit_bis <= datum_zeit_von || kandidat.datum_zeit_von >= datum_zeit_bis
|
|
96
|
+
#puts "#{self.class.name}#overlap: Keine Überlappung"
|
|
97
|
+
second = 0
|
|
98
|
+
reste << kandidat
|
|
99
|
+
else
|
|
100
|
+
raise ArbeitszeitkontoError, "overlap: Unbekannte Situation"
|
|
101
|
+
end
|
|
102
|
+
[seconds, reste]
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def to_s
|
|
106
|
+
"#{d_to_s(datum_zeit_von)} - #{d_to_s(datum_zeit_bis)}"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
private
|
|
110
|
+
|
|
111
|
+
def d_to_s dt
|
|
112
|
+
dt.strftime("%Y-%m-%d %H:%M:%S")
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'active_support/all'
|
|
2
|
+
|
|
3
|
+
require "arbeitszeitkonto/version"
|
|
4
|
+
require "arbeitszeitkonto/zeitspanne"
|
|
5
|
+
require "arbeitszeitkonto/zeitkonto_calculator"
|
|
6
|
+
require "arbeitszeitkonto/taeglich_zeitkonto_calculator"
|
|
7
|
+
require "arbeitszeitkonto/woechentlich_zeitkonto_calculator"
|
|
8
|
+
require "arbeitszeitkonto/feiertag_zeitkonto_calculator"
|
|
9
|
+
|
|
10
|
+
module Arbeitszeitkonto
|
|
11
|
+
class ArbeitszeitkontoError < StandardError; end
|
|
12
|
+
# Your code goes here...
|
|
13
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'arbeitszeitkonto'
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# def kombiniere(datum, zeit)
|
|
5
|
+
# zeit.change(year: datum.year, month: datum.month, day: datum.day)
|
|
6
|
+
# end
|
|
7
|
+
#
|
|
8
|
+
# vorlage_zeit = Time.new(2014, 8, 26, 12, 44)
|
|
9
|
+
#
|
|
10
|
+
# vorlage_fuer_datum = Time.new(2015, 8, 26, 8, 44)
|
|
11
|
+
#
|
|
12
|
+
#
|
|
13
|
+
# puts vorlage_zeit
|
|
14
|
+
# puts vorlage_fuer_datum
|
|
15
|
+
# neu = kombiniere vorlage_fuer_datum, vorlage_zeit
|
|
16
|
+
# puts neu
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# von = Time.new(2014, 8, 25, 23, 0, 0) #Samstag 23:00 Uhr
|
|
20
|
+
# bis = Time.new(2014, 8, 27, 06, 0, 0) #Montag 6:00 Uhr
|
|
21
|
+
# puts((bis.to_date - von.to_date).to_i)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def calculate_tage_zurueck(wday_calculator, wday_kandidat)
|
|
25
|
+
#anzahl_tage_zurueck = wday_kandidat >= wday_calculator ? wday_kandidat - wday_calculator : (wday_kandidat + 6) - wday_calculator
|
|
26
|
+
anzahl_tage_zurueck = (wday_kandidat - wday_calculator ) % 7
|
|
27
|
+
#puts "WoechentlichZeitKontoCalculator#calculate: Zeitspanne: wday Kandidat = #{wday_kandidat}, wday Calculator: #{wday_calculator}, anzahl_tage_zurueck: #{anzahl_tage_zurueck}"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# calculate_tage_zurueck(0, 1)
|
|
31
|
+
# calculate_tage_zurueck(2, 3)
|
|
32
|
+
# calculate_tage_zurueck(0, 6)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
calculate_tage_zurueck(3, 2)
|
metadata
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: arbeitszeitkonto
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.5.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Christian Mühlethaler
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-08-27 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.10'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.10'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.3'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.3'
|
|
55
|
+
description:
|
|
56
|
+
email:
|
|
57
|
+
- christian.muehlethaler@optor.ch
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".travis.yml"
|
|
64
|
+
- Gemfile
|
|
65
|
+
- README.md
|
|
66
|
+
- Rakefile
|
|
67
|
+
- arbeitszeitkonto.gemspec
|
|
68
|
+
- bin/console
|
|
69
|
+
- bin/setup
|
|
70
|
+
- lib/arbeitszeitkonto.rb
|
|
71
|
+
- lib/arbeitszeitkonto/feiertag_zeitkonto_calculator.rb
|
|
72
|
+
- lib/arbeitszeitkonto/taeglich_zeitkonto_calculator.rb
|
|
73
|
+
- lib/arbeitszeitkonto/version.rb
|
|
74
|
+
- lib/arbeitszeitkonto/woechentlich_zeitkonto_calculator.rb
|
|
75
|
+
- lib/arbeitszeitkonto/zeitkonto_calculator.rb
|
|
76
|
+
- lib/arbeitszeitkonto/zeitspanne.rb
|
|
77
|
+
- sandbox/time_manipulation.rb
|
|
78
|
+
homepage: http://www.planik.ch
|
|
79
|
+
licenses:
|
|
80
|
+
- MIT
|
|
81
|
+
metadata: {}
|
|
82
|
+
post_install_message:
|
|
83
|
+
rdoc_options: []
|
|
84
|
+
require_paths:
|
|
85
|
+
- lib
|
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: '0'
|
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
requirements: []
|
|
97
|
+
rubyforge_project:
|
|
98
|
+
rubygems_version: 2.4.8
|
|
99
|
+
signing_key:
|
|
100
|
+
specification_version: 4
|
|
101
|
+
summary: Berechnet die Zeiten für die verschiedenen Zeitkonti
|
|
102
|
+
test_files: []
|