{"id":13483826,"url":"https://github.com/abhidsm/time_diff","last_synced_at":"2025-03-27T15:30:34.553Z","repository":{"id":59159191,"uuid":"1442091","full_name":"abhidsm/time_diff","owner":"abhidsm","description":"Gem which calculates the difference between two times","archived":false,"fork":false,"pushed_at":"2018-05-14T01:58:32.000Z","size":915,"stargazers_count":146,"open_issues_count":7,"forks_count":21,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-17T14:15:10.161Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/time_diff","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/abhidsm.png","metadata":{"files":{"readme":"README","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":"2011-03-05T03:16:36.000Z","updated_at":"2024-01-30T20:15:15.000Z","dependencies_parsed_at":"2022-09-13T17:50:59.149Z","dependency_job_id":null,"html_url":"https://github.com/abhidsm/time_diff","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhidsm%2Ftime_diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhidsm%2Ftime_diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhidsm%2Ftime_diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhidsm%2Ftime_diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhidsm","download_url":"https://codeload.github.com/abhidsm/time_diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245871682,"owners_count":20686246,"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-07-31T17:01:15.686Z","updated_at":"2025-03-27T15:30:34.223Z","avatar_url":"https://github.com/abhidsm.png","language":"Ruby","readme":"= time_diff\nGem which calculates the difference between two time\n\n== Installation\n\n    gem install time_diff\n\n== Usage\n\n    require 'time_diff'\n\n    time_diff_components = Time.diff(start_date_time, end_date_time)\n\nThis will return the hash of time difference in terms of years, month, week, day, hour, minute and second.\n\nYou can use the difference like:\n\n    time_diff_components[:year], time_diff_components[:month], time_diff_components[:week]\n\n== Formatted Time difference\n\n    %y - year\n\n    %M - month\n\n    %w - week\n\n    %d - day\n\n    %H - hour\n\n    %N - minute\n\n    %S - second\n\n    %h - hour (without adding 'hour' text to the hours. eg: 3 for 3 hours)\n\n    %m - minute (without adding 'minute' text)\n\n    %s - second (without adding 'second' text)\n\nBy default the format is \n\n    '%y, %M, %w, %d and %h:%m:%s' \n\nthis will return \n\n    '1 year, 2 months, 3 weeks, 4 days and 12:05:52'.\n\nYou will get the result from the output hash, time_diff_components[:diff] \n\nYou can pass your own format as third parameter to this function.\n\nIf you give '%d %h' as the third parameter to the Time.diff() method, then the difference(time_diff_components[:diff]) will be calculated only in days and hours.\n\n== Examples\n\n    \u003e Time.diff(Time.parse('2011-03-06'), Time.parse('2011-03-07'))\n    =\u003e {:year =\u003e 0, :month =\u003e 0, :week =\u003e 0, :day =\u003e 1, :hour =\u003e 0, :minute =\u003e 0, :second =\u003e 0, :diff =\u003e '1 day and 00:00:00'}\n    \u003e Time.diff(Time.parse('2010-03-06 12:30:00'), Time.parse('2011-03-07 12:30:30'), '%y, %d and %h:%m:%s')\n    =\u003e {:year =\u003e 1, :month =\u003e 0, :week =\u003e 0, :day =\u003e 0, :hour =\u003e 18, :minute =\u003e 0, :second =\u003e 30, :diff =\u003e '1 year and 18:00:30'}\n    \u003e Time.diff(Time.parse('2011-03-06 12:30:00'), Time.parse('2011-03-07 12:30:30'), '%H %N %S')\n    =\u003e {:year =\u003e 0, :month =\u003e 0, :week =\u003e 0, :day =\u003e 1, :hour =\u003e 0, :minute =\u003e 0, :second =\u003e 30, :diff =\u003e '24 hours 0 minute 30 seconds'} \n\n== i18n support\n\n   Add locales for day, days, week, weeks, year, hour, hours, minute, minutes, second, and seconds in your YAML file. For eg:\n   en:\n     day: divasam\n     days: divasangal\n","funding_links":[],"categories":["Date and Time Processing"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhidsm%2Ftime_diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhidsm%2Ftime_diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhidsm%2Ftime_diff/lists"}