{"id":13507734,"url":"https://github.com/nurugger07/chronos","last_synced_at":"2025-04-09T20:13:39.945Z","repository":{"id":57482749,"uuid":"12245943","full_name":"nurugger07/chronos","owner":"nurugger07","description":"An elixir date/time library","archived":false,"fork":false,"pushed_at":"2018-04-04T02:52:21.000Z","size":184,"stargazers_count":90,"open_issues_count":0,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T20:13:35.656Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nurugger07.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-20T15:01:32.000Z","updated_at":"2024-12-10T10:08:06.000Z","dependencies_parsed_at":"2022-09-03T06:25:10.901Z","dependency_job_id":null,"html_url":"https://github.com/nurugger07/chronos","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/nurugger07%2Fchronos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurugger07%2Fchronos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurugger07%2Fchronos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurugger07%2Fchronos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nurugger07","download_url":"https://codeload.github.com/nurugger07/chronos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"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-08-01T02:00:38.375Z","updated_at":"2025-04-09T20:13:39.926Z","avatar_url":"https://github.com/nurugger07.png","language":"Elixir","funding_links":[],"categories":["Date and Time"],"sub_categories":[],"readme":"![Chronos](http://f.cl.ly/items/3W2Q0v2E3d0D0p412e1Z/7471443430_f127b84f8a_b.jpg)\n\n# Chronos [![Build Status](https://travis-ci.org/nurugger07/chronos.png?branch=master)](https://travis-ci.org/nurugger07/chronos)\n\nAn Elixir library for handling dates. Chronos can be used in both production and testing to quickly\ndetermine a date.\n\n## Using\n\nYou can add Chronos as a dependency in your `mix.exs` file. Since it only requires Elixir and Erlang there are no other dependencies.\n\n```elixir\ndef deps do\n  [ { :chronos, \"~\u003e 1.8.0\" } ]\nend\n```\n\nIf you aren't using hex, add the a reference to the github repo.\n\n``` elixir\ndef deps do\n  [ { :chronos, github: \"nurugger07/chronos\" } ]\nend\n```\n\nThen run `mix deps.get` in the shell to fetch and compile the dependencies\n\nTo use the Chronos date features in your project you can import the Chronos module or call the functions directly.\n\n```elixir\ndefmodule YourModule do\n\n  import Chronos\n\n  def get_today do\n    today\n  end\nend\n```\n\nor you can call functions without the import\n\n```elixir\ndefmodule YourModule do\n  def get_today do\n    Chronos.today\n  end\nend\n```\n\nThere are a number of functions to help with dates including below are some of the current APIs:\n\n```iex\n\n# yesterday without a date assumes you want the day before the current date\n# current date is {2012, 12, 21}\niex\u003e Chronos.yesterday\n{2012, 12, 20}\n\niex\u003e Chronos.tomorrow\n{2012, 12, 22}\n\n# epoch time can be return. If a time is not specified then midnight is assumed\niex\u003e Chronos.epoch_time {2012, 12, 21}\n1356048000\n\niex\u003e Chronos.epoch_time {{2012, 12, 21}, {11, 11, 0}}\n1356088260\n\n```\n\nYou can find the date for days or weeks in the past or future:\n\n```iex\niex\u003e Chronos.days_ago(3)\n{2012, 12, 18}\n\niex\u003e Chronos.weeks_ago(5)\n{2012, 11, 16}\n```\n\n## Use in Testing\n\nChronos is helpful in testing date based assertions because you can assign a default date or pass in a date to base the calculations on.\n\n```elixir\ndefmodule TestingModule do\n  use Chronos, date: {2012, 12, 21}\nend\n\n```\nIf the date option is set the default date for all functions will be that date.\n\n## Formatting Dates \u0026 Times\n\nWith the addition of Chronos.Formatter, you can begin to format date tuples to something more readable.\n\n```iex\n\niex\u003e Chronos.Formatter.strftime({2012, 12, 21}, \"%Y-%m-%d\")\n\"2012-12-21\"\n\niex\u003e Chronos.Formatter.strftime({2012, 12, 21}, \"Presented on %m/%d/%Y\")\n\"Presented on 12/21/2012\"\n\n```\n\nDate/Times can also be formatted with the `strftime` function.\n\n```iex\n\niex\u003e Chronos.Formatter.strftime({{2012, 12, 21}, {13, 35, 44}}, \"%Y-%m-%d %H:%M:%S\")\n\"2012-12-21 13:35:44\"\n\n```\n\nChronos will also build valid http dates.\n\nThe default format is for RFC 1123:\n\n``` iex\niex\u003e Chronos.Formatter.http_date({{2012, 12, 21}, {13, 35, 44}})\n\"Fri, 21 Dec 2012 18:31:45 GMT\"\n```\n\nHowever, there is also support for RFC 850 \u0026 ANSI C's asctime() format\n\n``` iex\niex\u003e Chronos.Formatter.http_date({{2012, 12, 21}, { 13, 31, 45 }}, :rfc850)\n\"Friday, 21-Dec-2012 18:31:45 GMT\"\n\niex\u003e Chronos.Formatter.http_date({{2012, 12, 21}, { 13, 31, 45 }}, :asctime)\n\"Fri Dec 21 18:31:45 2012\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnurugger07%2Fchronos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnurugger07%2Fchronos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnurugger07%2Fchronos/lists"}