{"id":32174429,"url":"https://github.com/nerves-time/nerves_time","last_synced_at":"2026-02-21T12:01:28.545Z","repository":{"id":39751046,"uuid":"144434204","full_name":"nerves-time/nerves_time","owner":"nerves-time","description":"Keep time in sync on Nerves devices","archived":false,"fork":false,"pushed_at":"2025-10-24T01:01:49.000Z","size":201,"stargazers_count":23,"open_issues_count":8,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-11-01T08:15:16.498Z","etag":null,"topics":["elixir","hacktoberfest","nerves","ntp"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nerves-time.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSES/Apache-2.0.txt","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,"zenodo":null}},"created_at":"2018-08-12T03:15:12.000Z","updated_at":"2025-10-10T16:33:12.000Z","dependencies_parsed_at":"2023-01-31T07:30:31.663Z","dependency_job_id":"9a1b172f-60e6-4aa3-b9a5-f05cc5802856","html_url":"https://github.com/nerves-time/nerves_time","commit_stats":{"total_commits":152,"total_committers":11,"mean_commits":"13.818181818181818","dds":0.4144736842105263,"last_synced_commit":"f9afb7ec604bb37044e671af2f9fe43583f9af5e"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/nerves-time/nerves_time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerves-time%2Fnerves_time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerves-time%2Fnerves_time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerves-time%2Fnerves_time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerves-time%2Fnerves_time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nerves-time","download_url":"https://codeload.github.com/nerves-time/nerves_time/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerves-time%2Fnerves_time/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29680147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T11:29:27.227Z","status":"ssl_error","status_checked_at":"2026-02-21T11:29:20.292Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["elixir","hacktoberfest","nerves","ntp"],"created_at":"2025-10-21T19:01:31.567Z","updated_at":"2026-02-21T12:01:28.539Z","avatar_url":"https://github.com/nerves-time.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nerves_time\n\n[![Hex version](https://img.shields.io/hexpm/v/nerves_time.svg \"Hex version\")](https://hex.pm/packages/nerves_time)\n[![API docs](https://img.shields.io/hexpm/v/nerves_time.svg?label=hexdocs \"API docs\")](https://hexdocs.pm/nerves_time/NervesTime.html)\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/nerves-time/nerves_time/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/nerves-time/nerves_time/tree/main)\n[![REUSE status](https://api.reuse.software/badge/github.com/nerves-time/nerves_time)](https://api.reuse.software/info/github.com/nerves-time/nerves_time)\n\n`NervesTime` keeps the system clock on [Nerves](http://nerves-project.org)\ndevices in sync when connected to the network and close to in sync when\ndisconnected. It's especially useful for devices lacking a [Battery-backed\nreal-time clock](https://en.wikipedia.org/wiki/Real-time_clock) and will advance\nthe clock at startup to a reasonable guess.\n\n## Installation\n\nFirst add `nerves_time` to your project's dependencies:\n\n```elixir\ndef deps do\n  [\n    {:nerves_time, \"~\u003e 0.4.2\"}\n  ]\nend\n```\n\nEnsure that your `vm.args` allows for\n[timewarps](http://erlang.org/doc/apps/erts/time_correction.html#time-warp-modes).\nIf it doesn't, `nerves_time` will update the OS system time, but Erlang's system\ntime will lag. The following line should be in the beginning or middle of the\n`vm.args` file:\n\n```elixir\n+C multi_time_warp\n```\n\nIf you're using one of the official Nerves Systems, then this is all that's\nneeded. `nerves_time` requires Busybox's `ntpd` and `date` applets to be\nenabled. If you haven't explicitly disabled them, they're probably enabled.\n\n## Configuration\n\n### Startup\n\n`nerves_time` by default does not block waiting for a valid system time to be set.\nThis can result in your application running before the time has been adjusted, which\nmay be undesirable. To lessen the likelyhood of that happening you can adjust\nthe `:await_initialization_timeout` config to wait for a valid system time to be set.\nIf `nerves_time` fails to do that within the given timeframe it will stop blocking\nstartup and continue trying asynchronously.\n\n```elixir\n# config/config.exs\n\nconfig :nerves_time, await_initialization_timeout: :timer.seconds(5)\n```\n\n### NTP\n\n`nerves_time` uses [ntp.pool.org](https://www.ntppool.org/en/) for time\nsynchronization. Please see their [terms of\nuse](https://www.ntppool.org/tos.html) before tweaking `nerves_time`.\nAlternative NTP servers can be specified using the `config.exs`:\n\n```elixir\n# config/config.exs\n\nconfig :nerves_time, :servers, [\n    \"0.pool.ntp.org\",\n    \"1.pool.ntp.org\",\n    \"2.pool.ntp.org\",\n    \"3.pool.ntp.org\"\n  ]\n```\n\nIt's also possible to configure NTP servers at runtime. See\n`NervesTime.set_ntp_servers/1`.\n\n### Valid time range\n\n`nerves_time` has a concept of a valid time range. This minimizes time\nerrors on systems without clocks or Internet connections or that may have some\nissue that causes a very wrong time value. The default valid time range is\nhardcoded and moves forward each release. It is not the build timestamp since\nthat results in [non-reproducible builds](https://reproducible-builds.org).\nApplications can override the valid range via the application config:\n\n```elixir\n# config/config.exs\n\nconfig :nerves_time, earliest_time: ~N[2019-10-04 00:00:00], latest_time: ~N[2022-01-01 00:00:00]\n```\n\n## Algorithm\n\nHere's the basic idea behind `nerves_time`:\n\n* If the clock hasn't been set or is invalid, set it to the earliest valid\n  time known to `nerves_time`. This is either set in the application config or\n  defaulted to a reasonable value that likely moves forward a little each\n  `nerves_time` release.\n* check for time via a [Real Time Clock](#Real-Time-Clock)\n* Run Busybox `ntpd` to synchronize time using the [NTP\n  protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol).\n* Update [Real Time Clock](#Real-Time-Clock) periodically and on graceful power\n  downs. This is currently only done at around 11 minute intervals.\n\nTo check the NTP synchronization status, call `NervesTime.synchronized?/0`.\n\n## Real Time Clock\n\nA hardware based real time clock can be configured by added a config.exs entry:\n\n```elixir\nconfig :nerves_time, rtc: {SomeImplementingModule, [some: :initialization_opt]}\n```\n\nBy default Nerves Time is configured to use `NervesTime.FileTime` which will\nCheck for `~/.nerves_time`. If it exists, advance the clock to it's last\nmodification time.\n\nSee the documentation for `NervesTime.RealTimeClock` to implement your own\nreal time clock.\n\n## Credits and license\n\nThis project started as a fork of\n[nerves_ntp](https://hex.pm/packages/nerves_ntp) by Marcin Operacz and Wojciech\nMandrysz. It has quite a few changes from since when they worked on the project,\nbut some of their code still exists. Both their project and this one are covered\nby the [Apache-2.0 license](https://opensource.org/licenses/Apache-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerves-time%2Fnerves_time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnerves-time%2Fnerves_time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerves-time%2Fnerves_time/lists"}