punch_time
Work time calculations using punch clock.
See It Work
Features
Calculates a work, a tardy, a overtime work and a night work times.
Motivation
Proud to present our newest line of gem, the back office calculations series. As you know, the modern human resource calculations has been needing a large variety of case. This gem include simplest calculator for overtime work, night work and tardy time. If you would kindly accept the deliverable, this gem willing to calculation.
Installation
Add this line to your application's Gemfile:
gem 'punch_time'
And then execute:
$ bundle
Or install it yourself as:
$ gem install punch_time
Configuration
PunchTime.configure do |config|
config.shift_in_time = Time.parse('10:00')
config.shift_out_time = Time.parse('19:00')
config.breaks = [
{
start_time: Time.parse('12:00'),
end_time: Time.parse('13:00')
}
]
config.night = {
start_time: Time.parse('22:00'),
end_time: Time.parse('05:00')
}
config.offset = '+0000'
end
Usage
# Set the your time record
PunchTime.punch(DateTime.parse('20200101 10:10'), DateTime.parse('20200101 19:00'))
# Calculations can be performed in minutes, hours, or days
p PunchTime.sum_work.hours
# => 8
p PunchTime.sum_work.minutes
# => 480
# When need calculate holiday work time (use with business_time)
require 'business_time'
sum_works = []
Date.parse('20200101').upto(Date.parse('20200105')) do |x|
PunchTime.punch(DateTime.parse(x.to_s + ' 10:10'), DateTime.parse(x.to_s + ' 19:00'))
sum_works.append(PunchTime.sum_work.hours) unless x.workday?
end
p sum_works.inject(:+).to_i
# => 16
# Other methods
PunchTime.sum_work
PunchTime.sum_tardy
PunchTime.sum_over_work
PunchTime.sum_night_work
PunchTime.tardy?
PunchTime.overtime_work?
PunchTime.night_overtime_work?
Contributing
Bug reports and pull requests are welcome on GitHub at https://bitbucket.org/smapira/punch_time. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Changelog
punch_time's changelog is available here.
Code of Conduct
Everyone interacting in the PunchClock project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
You may enjoy owning other libraries and my company.
- routeflagsinc / jma — Bitbucket
- for the Japan Meteorological Agency (気象庁) for searching new information simplifies.
- smapira / punch_time — Bitbucket
- Work time calculations using punch clock.
- smapira / rspec-css — Bitbucket
- Record your test suite's computed CSS during future test runs for deterministic and accurate tests.
- routeflags/timeline_rails_helper: The TimelineRailsHelper provides a timeline_molecules_tag helper to draw a vertical time line usable with vanilla CSS.
- routeflags/acts_as_tree_diagram: ActsAsTreeDiagram extends ActsAsTree to add simple function for draw tree diagram with html.
- 株式会社旗指物