{"id":16073681,"url":"https://github.com/phstc/acts_as_working_days","last_synced_at":"2025-04-16T07:39:47.253Z","repository":{"id":1191495,"uuid":"1095686","full_name":"phstc/acts_as_working_days","owner":"phstc","description":"acts_as_working_days is a Rails plugin to add working days on models","archived":false,"fork":false,"pushed_at":"2014-04-11T12:45:34.000Z","size":188,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T05:11:37.262Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://pablocantero.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phstc.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-11-19T19:57:12.000Z","updated_at":"2014-04-11T12:45:34.000Z","dependencies_parsed_at":"2022-08-16T12:30:59.364Z","dependency_job_id":null,"html_url":"https://github.com/phstc/acts_as_working_days","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Facts_as_working_days","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Facts_as_working_days/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Facts_as_working_days/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Facts_as_working_days/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phstc","download_url":"https://codeload.github.com/phstc/acts_as_working_days/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248884268,"owners_count":21177383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T08:22:10.328Z","updated_at":"2025-04-16T07:39:47.191Z","avatar_url":"https://github.com/phstc.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= ActsAsWorkingDays\n\nacts_as_working_days is a Rails plugin to add working days to your models\n\n== Usage\n\n=== Adding acts_as_working_days\n\n # app/models/company.rb\n class Company \u003c ActiveRecord::Base\n   acts_as_working_days\n end\n\n=== Verifying a working day\n\n kwik_e_mart = Company.new(:name =\u003e 'Kwik-E-Mart')\n \n # Verifies if kwik_e_mart is opened now (Time.now)\n kwik_e_mart.working_day? \n \n # Verifies if kwik_e_mart is opened on Sundays\n kwik_e_mart.working_day?(:week_day =\u003e 0)\n \n # Verifies if kwik_e_mart is opened on Mondays 21h30\n kwik_e_mart.working_day?(:week_day =\u003e 1, :hour =\u003e 21, :min =\u003e 30)\n\nweek_day is an integer representing the day of the week, 0..6, with Sunday == 0.\n(See http://www.ruby-doc.org/core-2.1.1/Time.html#method-i-wday)\n\n=== Setting working days\n\n kwik_e_mart = Company.new(:name =\u003e 'Kwik-E-Mart')\n\n # Set kwik_e_mart is opened on Mondays from 8h30 to 18h45\n kwik_e_mart.working_days.build(:week_day =\u003e 1, :start_hour =\u003e 8, :start_min =\u003e 30, :end_hour =\u003e 18, :end_min =\u003e 45)\n\n # Set kwik_e_mart is opened on Saturdays from 10h00 to 16h00\n kwik_e_mart.working_days.build(:week_day =\u003e 6, :start_hour =\u003e 10, :start_min =\u003e 0, :end_hour =\u003e 16, :end_min =\u003e 0)\n \n # retuns true\n kwik_e_mart.working_day?(:week_day =\u003e 1)\n\n # returns true\n kwik_e_mart.working_day?(:week_day =\u003e 1, :hour =\u003e 18)\n\n # return true\n kwik_e_mart.working_day?(:week_day =\u003e 1, :hour =\u003e 12, :min =\u003e 30)\n\n # return false\n kwik_e_mart.working_day?(:week_day =\u003e 1, :hour =\u003e 21, :min =\u003e 30)\n\n=== Creating html form to set the working days\n\n  # app/views/company/new.html.erb\n  \u003c% form_for @company do |f| %\u003e\n    \u003c%= f.error_messages %\u003e\n    \u003ch2\u003eCompany fields\u003c/h2\u003e\n    \u003cp\u003e\n      \u003c%= f.label :name, 'Company name' %\u003e\u003cbr/\u003e\n      \u003c%= f.text_field :name %\u003e\n    \u003c/p\u003e\n    \u003ch2\u003eWorkings days\u003c/h2\u003e\n    \u003ctable id=\"table-working-days\"\u003e\n      \u003cthead\u003e\n        \u003ctr\u003e\n          \u003cth\u003eDay\u003c/th\u003e\n          \u003cth\u003eOpen\u003c/th\u003e\n          \u003cth\u003eClose\u003c/th\u003e\n        \u003c/tr\u003e\n      \u003c/thead\u003e\n      \u003ctbody\u003e\n        \u003c% f.fields_for :working_days, @address.working_days_defaults do | working_day_form | %\u003e\n        \u003ctr\u003e\n          \u003c!-- I18n week_day.day_0...day_6, Sunday..Saturday --\u003e\n          \u003ctd\u003e\u003c%=  t \"week_day.day_#{working_day_form.object.week_day}\" %\u003e\u003c/td\u003e\n          \u003ctd\u003e\n            \u003c%= working_day_form.hidden_field :week_day %\u003e\n            \u003c%= working_day_form.select :start_hour, 0..23, {}, {:class =\u003e 'select'}  %\u003e\n            \u003c%= working_day_form.select :start_min, 0..59, {}, {:class =\u003e 'select'}  %\u003e\n          \u003c/td\u003e\n          \u003ctd\u003e\n            \u003c%= working_day_form.select :end_hour, 0..23, {}, {:class =\u003e 'select'}  %\u003e\n            \u003c%= working_day_form.select :end_min, 0..59, {}, {:class =\u003e 'select'}  %\u003e\n          \u003c/td\u003e\n        \u003c/tr\u003e\n      \u003c% end %\u003e\n      \u003c/tbody\u003e\n    \u003ctable\u003e\n  \u003c% end %\u003e\n\n=== Creating I18n file to translate numeric week day to string\n\t\n #config/locales/en.yml\n week_day:\n   day_0: Sunday\n   day_1: Monday\n   day_2: Tuesday\n   day_3: Wednesday\n   day_4: Thursday\n   day_5: Friday\n   day_6: Saturday\n  \n\n=== Setting rails application time zone\n\nDon't forget to set the time zone in your Rails application enviroment \n\n # config/enviroment.rb\n Rails::Initializer.run do |config|\n   #...\n   config.time_zone = 'Brasilia'\n   #...\n end\n\nTo list all supported time zones \n $ rake time:zones:all\n\n(See http://wiki.rubyonrails.org/howtos/time-zones)\n\n== Installation\n\n=== Rails 2.3.x\n\n==== Plugin\n\n  script/plugin install git://github.com/phstc/acts_as_working_days\n\n==== Gem \n \n  # config/environment.rb:\n  config.gem 'acts_as_working_days'\n\n\n==== Post Installation\n\n1. script/generate acts_as_working_days_migration\n2. rake db:migrate\n\n=== Rails 3.0\n\n==== Plugin\n\n  script/plugin install git://github.com/phstc/acts_as_working_days\n\n==== Post Installation\n\n1. rails generate acts_as_working_days:migration\n2. rake db:migrate\n\n== Testing\n\n rake test\n\nCopyright (c) 2010 Pablo Cantero, released under the MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphstc%2Facts_as_working_days","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphstc%2Facts_as_working_days","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphstc%2Facts_as_working_days/lists"}