{"id":15033183,"url":"https://github.com/fegoa89/date-manager","last_synced_at":"2026-01-30T10:55:04.895Z","repository":{"id":30610501,"uuid":"34165793","full_name":"fegoa89/Date-Manager","owner":"fegoa89","description":"Parse, validate, manipulate, and display dates.","archived":false,"fork":false,"pushed_at":"2016-07-20T19:55:12.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T18:55:04.964Z","etag":null,"topics":["date","date-time","ruby"],"latest_commit_sha":null,"homepage":null,"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/fegoa89.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-18T12:54:55.000Z","updated_at":"2018-12-11T11:22:54.000Z","dependencies_parsed_at":"2022-08-26T12:52:05.210Z","dependency_job_id":null,"html_url":"https://github.com/fegoa89/Date-Manager","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/fegoa89%2FDate-Manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fegoa89%2FDate-Manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fegoa89%2FDate-Manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fegoa89%2FDate-Manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fegoa89","download_url":"https://codeload.github.com/fegoa89/Date-Manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243351841,"owners_count":20276908,"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":["date","date-time","ruby"],"created_at":"2024-09-24T20:20:20.146Z","updated_at":"2026-01-30T10:55:04.857Z","avatar_url":"https://github.com/fegoa89.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://semaphoreci.com/api/v1/projects/c1127eeb-9c13-44dd-baeb-155ce4a54493/425379/badge.svg)](https://semaphoreci.com/fegoa89/date-manager)\n# DateManager\n\nParse, validate, manipulate, and display dates.\n\n# Start\n\nDateManager is a gem for convert/parse/compare two strings into date a DateTime object and manipulate them .\nFor handle different dates format, I did this gem based on the most used formats in different countries (https://en.wikipedia.org/wiki/Date_format_by_country#Listing), from where I can divide it in three basic types :\n\n- MDY - Month/Day/Year mm/dd/yyyy\n- DMY - Day/Month/Year dd/mm/yyyy\n- YMD - Year/Month/Day yyyy/mm/dd\n\n# Using DateManager\n\nCreate an instance:\n\n    $ @dates = DateManager.new('2012/02/02', '2012/02/03')\n\nThe standard string input is the YMD format .\n\nYou can set any other string input format (Like day - month - year) passing the date format as a third parameter like :\n\n    $ @dates = DateManager.new('02/03/2015', '03/03/2015', 'DMY')\n\nor\n\n    $ @dates = DateManager.new('12/30/2015', '12/31/2015', 'MDY')\n\n\nIf the format is given as a DMY ( for example) and it does not contains a third parameter that indicates that the strings given are build on this format, the first date and the last date wont be possible to get set .\nYou can use a '.' , '-' or '/' as a component separator for separate the different components of the dates, it will be translated into '/'.\n\nAfter a succesfull creation of an object, keep in mind the date range you are passing. The first date (first string given) should be older than the second date (second string given). If not it does not have sense (you can test it calling the method '#valid_date_range?' . The purpose of this gem is play between the dates of two dates :) )\n\n# Methods\n\n## start_date\nReturns the start_date object :\n\n    $ @dates = DateManager.new('02/03/2015', '03/03/2015', 'DMY')\n    $ @dates.start_date\n    $ #\u003cDateTime: 2015-03-02T00:00:00+00:00 ((2457084j,0s,0n),+0s,2299161j)\u003e\n\n## finish_date\nReturns the finish_date object :\n\n    $ @dates = DateManager.new('02/03/2015', '03/03/2015', 'DMY')\n    $ @dates.finish_date\n    $ #\u003cDateTime: 2015-03-03T00:00:00+00:00 ((2457085j,0s,0n),+0s,2299161j)\u003e\n\n## format\nReturns the date format :\n\n    $ @dates = DateManager.new('02/03/2015', '03/03/2015', 'DMY')\n    $ @dates.format\n    $ DMY\n\n## valid_date_range?\n\nCompares if the first string given is a date older than the second string given .\n\n    $ @dates = DateManager.new('02/03/2015', '03/03/2015', 'DMY')\n    $ @dates.valid_date_range?\n    $ true\n\n## days_between_dates\n\nGives back the quantity of days between these dates\n\n    $ @dates = DateManager.new('02/03/2015', '03/03/2015', 'DMY')\n    $ @dates.days_between_dates\n    $ 1\n\n## months_between_dates\n\nGives back the quantity of months between these dates\n\n    $ @dates = DateManager.new('02/02/2015', '03/03/2015', 'DMY')\n    $ @dates.months_between_dates\n    $ 1\n\n## years_between_dates\n\nGives back the quantity of years between these dates\n\n    $ @dates = DateManager.new('03/03/2014', '03/03/2015', 'DMY')\n    $ @dates.years_between_dates\n    $ 1\n\n## start_date_leap_year?\n\nReturns true or false depending if the start_date object is a leap year or not\n    $ @dates = DateManager.new('03/03/2014', '03/03/2015', 'DMY')\n    $ @dates.start_date_leap_year?\n    $ false\n\n## finish_date_leap_year?\n\nReturns true or false depending if the finish_date object is a leap year or not\n\nGives back the quantity of years between these dates\n\n    $ @dates = DateManager.new('03/03/2014', '03/03/2016', 'DMY')\n    $ @dates.finish_date_leap_year?\n    $ true\n\n## differences_between_dates\n\nReturns a hash containing the quantity of years / months / days between the dates\n\n    $ @dates = DateManager.new('03/03/2014', '03/03/2016', 'DMY')\n    $ @dates.differences_between_dates\n    $ {:years=\u003e2, :months=\u003e24, :days=\u003e731}\n\n## readable_days_between_dates(language = {})\n\nReturns a string with quantity of days in between. Only Spanish and English are supported.\n\n    $ @dates = DateManager.new('02/02/2015', '03/03/2015', 'DMY')\n    $ @dates.readable_days_between_dates\n    $ 29 days\n\n## readable_months_between_dates(language = {})\n\nReturns a string with the quantity of months in between. Only Spanish and English are supported.\n\n    $ @dates = DateManager.new('02/02/2015', '03/04/2015', 'DMY')\n    $ @dates.readable_months_between_dates\n    $ 2 months\n\n## human_readable_format\n\nReturns a string with start_date and finish_date object in a human readable way that contains the day in a ordinal format. Only Spanish and English are supported.\n\n    $ @dates = DateManager.new('2012/02/01', '2012/02/03')\n    $ @dates.human_readable_format\n    $ \"First date : Wednesday, 1st of February 2012 - Second date : Friday, 3rd of February 2012\"\n\n## working_days\n\nReturn quantity of working days between dates\n\n    $ @dates = DateManager.new('2012/02/01', '2012/02/03')\n    $ @dates.working_days\n    $ 3\n\n## total_weekend_days\n\nReturn quantity of saturdays / sundays between dates\n\n    $ @dates = DateManager.new('2015/01/30', '2015/02/13')\n    $ @dates.total_weekend_days\n    $ 4\n\n# Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'date_manager'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install date_manager\n\n\n# Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffegoa89%2Fdate-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffegoa89%2Fdate-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffegoa89%2Fdate-manager/lists"}