{"id":13393213,"url":"https://github.com/bitwalker/timex","last_synced_at":"2025-05-14T09:06:21.668Z","repository":{"id":19077992,"uuid":"22305306","full_name":"bitwalker/timex","owner":"bitwalker","description":"A complete date/time library for Elixir projects.","archived":false,"fork":false,"pushed_at":"2024-12-23T21:15:04.000Z","size":2611,"stargazers_count":1772,"open_issues_count":66,"forks_count":392,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-14T09:03:46.508Z","etag":null,"topics":["calendar","datetime","elixir"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/timex","language":"Elixir","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/bitwalker.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-27T06:53:52.000Z","updated_at":"2025-05-11T09:18:53.000Z","dependencies_parsed_at":"2024-11-06T00:03:04.513Z","dependency_job_id":"f45d361d-84e5-4c3e-87fd-a8b68af70b27","html_url":"https://github.com/bitwalker/timex","commit_stats":{"total_commits":1063,"total_committers":213,"mean_commits":4.990610328638498,"dds":0.4129821260583255,"last_synced_commit":"17806a9fb55876a58cadbd2c4133d49891c6036a"},"previous_names":[],"tags_count":121,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwalker%2Ftimex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwalker%2Ftimex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwalker%2Ftimex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwalker%2Ftimex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitwalker","download_url":"https://codeload.github.com/bitwalker/timex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254110374,"owners_count":22016391,"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":["calendar","datetime","elixir"],"created_at":"2024-07-30T17:00:46.558Z","updated_at":"2025-05-14T09:06:21.647Z","avatar_url":"https://github.com/bitwalker.png","language":"Elixir","readme":"## Timex\n\n[![Master](https://github.com/bitwalker/timex/workflows/elixir/badge.svg?branch=master)](https://github.com/bitwalker/timex/actions?query=workflow%3A%22elixir%22+branch%3Amaster)\n[![Hex.pm Version](https://img.shields.io/hexpm/v/timex.svg?style=flat)](https://hex.pm/packages/timex)\n[![Coverage Status](https://coveralls.io/repos/github/bitwalker/timex/badge.svg?branch=master)](https://coveralls.io/github/bitwalker/timex?branch=master)\n\nTimex is a rich, comprehensive Date/Time library for Elixir projects, with full timezone support via the `:tzdata` package. If\nyou need to manipulate dates, times, datetimes, timestamps, etc., then Timex is for you! It is very easy to use Timex types\nin place of default Erlang types, as well as Ecto types via the `timex_ecto` package.\n\nThe complete documentation for Timex is located [here](https://hexdocs.pm/timex).\n\n## Migrating to Timex 3.x\n\nIf you are coming from an earlier version of Timex, it is recommended that you evaluate whether or not the functionality provided\nby the standard library `Calendar` API is sufficient for your needs, as you may be able to avoid the dependency entirely.\n\nFor those that require Timex for one reason or another, Timex now delegates to the standard library where possible, and provides\nbackward compatibility to Elixir 1.8 for APIs which are used. This is to avoid duplicating effort, and to ease the maintenance of\nthis library in the future. Take a look at the documentation to see what APIs are available and how to use them. Many of them may have\nchanged, been removed/renamed, or have had their semantics improved since early versions of the library, so if you are coming from\nan earlier version, you will need to review how you are using various APIs. The CHANGELOG is a helpful document to sort through what\nhas changed in general.\n\nTimex is primarily oriented around the Olson timezone database, and so you are encouraged to use those timezones in favor of alternatives. \nTimex does provide compatibility with the POSIX-TZ standard, which allows specification of custom timezones, see \n[this document](https://pubs.opengroup.org/onlinepubs/9699919799/) for more information. Timex does not provide support\nfor timezones which do not adhere to one of those two standards. While Timex attempted to support timezone abbreviations without context\nin prior versions, this was broken, and has been removed.\n\n## Getting Started\n\nThere are some brief examples on usage below, but I highly recommend you review the\nAPI docs [here](https://hexdocs.pm/timex), there are many examples, and some extra pages with\nricher documentation on specific subjects such as custom formatters/parsers, etc.\n\n### Quickfast introduction\n\nTo use Timex, I recommend you add `use Timex` to the top of the module where you will be working with Timex modules,\nall it does is alias common types so you can work with them more comfortably. If you want to see the specific aliases\nadded, check the top of the `Timex` module, in the `__using__/1` macro definition.\n\nHere's a few simple examples:\n\n```elixir\n\u003e use Timex\n\u003e Timex.today()\n~D[2016-02-29]\n\n\u003e datetime = Timex.now()\n#\u003cDateTime(2016-02-29T12:30:30.120+00:00Z Etc/UTC)\n\n\u003e Timex.now(\"America/Chicago\")\n#\u003cDateTime(2016-02-29T06:30:30.120-06:00 America/Chicago)\n\n\u003e Duration.now()\n#\u003cDuration(P46Y6M24DT21H57M33.977711S)\u003e\n\n\u003e {:ok, default_str} = Timex.format(datetime, \"{ISO:Extended}\")\n{:ok, \"2016-02-29T12:30:30.120+00:00\"}\n\n\u003e {:ok, relative_str} = Timex.shift(datetime, minutes: -3) |\u003e Timex.format(\"{relative}\", :relative)\n{:ok, \"3 minutes ago\"}\n\n\u003e strftime_str = Timex.format!(datetime, \"%FT%T%:z\", :strftime)\n\"2016-02-29T12:30:30+00:00\"\n\n\u003e Timex.parse(strftime_str, \"{ISO:Extended}\")\n{:ok, #\u003cDateTime(2016-02-29T12:30:30.120+00:00 Etc/Utc)}\n\n\u003e Timex.parse!(strftime_str, \"%FT%T%:z\", :strftime)\n#\u003cDateTime(2016-02-29T12:30:30.120+00:00 Etc/Utc)\n\n\u003e Duration.diff(Duration.now(), Duration.zero(), :days)\n16850\n\n\u003e Timex.shift(date, days: 3)\n~D[2016-03-03]\n\n\u003e Timex.shift(datetime, hours: 2, minutes: 13)\n#\u003cDateTime(2016-02-29T14:43:30.120Z Etc/UTC)\u003e\n\n\u003e timezone = Timezone.get(\"America/Chicago\", Timex.now())\n#\u003cTimezoneInfo(America/Chicago - CDT (-06:00:00))\u003e\n\n\u003e Timezone.convert(datetime, timezone)\n#\u003cDateTime(2016-02-29T06:30:30.120-06:00 America/Chicago)\u003e\n\n\u003e Timex.before?(Timex.today(), Timex.shift(Timex.today, days: 1))\ntrue\n\n\u003e Timex.before?(Timex.shift(Timex.today(), days: 1), Timex.today())\nfalse\n\n\u003e interval = Timex.Interval.new(from: ~D[2016-03-03], until: [days: 3])\n%Timex.Interval{from: ~N[2016-03-03 00:00:00], left_open: false,\n right_open: true, step: [days: 1], until: ~N[2016-03-06 00:00:00]}\n\n\u003e ~D[2016-03-04] in interval\ntrue\n\n\u003e ~N[2016-03-04 00:00:00] in interval\ntrue\n\n\u003e ~N[2016-03-02 00:00:00] in interval\nfalse\n\n\u003e Timex.Interval.overlaps?(Timex.Interval.new(from: ~D[2016-03-04], until: [days: 1]), interval)\ntrue\n\n\u003e Timex.Interval.overlaps?(Timex.Interval.new(from: ~D[2016-03-07], until: [days: 1]), interval)\nfalse\n\n```\n\nThere are a ton of other functions, all of which work with Erlang datetime tuples, Date, NaiveDateTime, and DateTime. \nThe Duration module contains functions for working with Durations, including Erlang timestamps (such as those returned from `:timer.tc`)\n\n## Extensibility\n\nTimex exposes a number of extension points for you, in order to accommodate different use cases:\n\nTimex itself defines its core operations on the Date, DateTime, and NaiveDateTime types using the `Timex.Protocol` protocol. \nFrom there, all other Timex functionality is derived. If you have custom date/datetime types you want to use with Timex, \nthis is the protocol you would need to implement.\n\nTimex also defines a `Timex.Comparable` protocol, which you can extend to add comparisons to custom date/datetime types.\n\nYou can provide your own formatter/parser for datetime strings by implementing the `Timex.Format.DateTime.Formatter` \nand/or `Timex.Parse.DateTime.Parser` behaviours, depending on your needs.\n\n### Timex with escript\n\nIf you need to use Timex from within an escript, add `{:tzdata, \"~\u003e 0.1.8\", override: true}` to your deps, more recent versions of :tzdata are unable to work in an escript because of the need to load ETS table files from priv, and due to the way ETS loads these files, it's not possible to do so.\n\nIf your build still throws an error after this, try removing the `_build` and `deps` folder. Then execute `mix deps.unlock tzdata` and `mix deps.get`.\n\n### Automatic time zone updates\n\nTimex includes the [Tzdata](https://github.com/lau/tzdata) library for time zone data.\nTzdata has an automatic update capability that fetches updates from IANA and which is enabled by default; \nif you want to disable it, check [the Tzdata documentation](https://github.com/lau/tzdata#automatic-data-updates) for details.\n\n## License\n\nThis software is licensed under [the MIT license](LICENSE.md).\n","funding_links":[],"categories":["Date and Time","Elixir","Tools"],"sub_categories":["Mesh networks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitwalker%2Ftimex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitwalker%2Ftimex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitwalker%2Ftimex/lists"}