{"id":47851327,"url":"https://github.com/SuaveIV/nu_script_time_sync","last_synced_at":"2026-04-19T03:00:53.212Z","repository":{"id":343653835,"uuid":"1178589773","full_name":"SuaveIV/nu_script_time_sync","owner":"SuaveIV","description":"A Nushell script that checks whether your system clock has drifted, using the Time.now API.","archived":false,"fork":false,"pushed_at":"2026-03-11T07:32:20.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-11T14:10:22.090Z","etag":null,"topics":["nushell","nushell-script","time-sync","timenow"],"latest_commit_sha":null,"homepage":"","language":"Nushell","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/SuaveIV.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-11T07:01:26.000Z","updated_at":"2026-03-11T07:32:23.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/SuaveIV/nu_script_time_sync","commit_stats":null,"previous_names":["suaveiv/nu_script_time_sync"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/SuaveIV/nu_script_time_sync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuaveIV%2Fnu_script_time_sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuaveIV%2Fnu_script_time_sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuaveIV%2Fnu_script_time_sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuaveIV%2Fnu_script_time_sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SuaveIV","download_url":"https://codeload.github.com/SuaveIV/nu_script_time_sync/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuaveIV%2Fnu_script_time_sync/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31992822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["nushell","nushell-script","time-sync","timenow"],"created_at":"2026-04-03T22:00:21.651Z","updated_at":"2026-04-19T03:00:53.204Z","avatar_url":"https://github.com/SuaveIV.png","language":"Nushell","readme":"# time-sync.nu\n\n[![Nushell](https://img.shields.io/badge/Nushell-%3E%3D0.111-4E9900.svg?logo=nushell)](https://www.nushell.sh/)\n[![Time.now API](https://img.shields.io/badge/Powered%20by-Time.now-blue)](https://time.now/developer)\n\nA Nushell script to check if your system clock is drifting. It queries the [Time.now API](https://time.now/developer/), compares the result to your local time, and tells you if your clock is out of sync.\n\n## Why I wrote this\n\nSystem clocks drift. Most of the time NTP handles it, but when it fails (suspended VMs, weird service configs, air-gapped machines), it fails silently and messes up your logs. I wanted a quick sanity check without having to remember the flags for `timedatectl` or parse `ntpq` output.\n\n## Usage\n\n### Run it once\n\n```nushell\nnu time-sync.nu\n```\n\n### Install as a command\n\nUse it as a module in your `config.nu` to use it anywhere:\n\n```nushell\nuse /path/to/time-sync.nu\n```\n\nThen run it:\n\n```nushell\ntime-sync\ntime-sync --max-offset 10sec\ntime-sync --raw\n```\n\nThis prints a formatted report:\n\n\u003cimg width=\"400\" height=\"191\" alt=\"image\" src=\"https://github.com/user-attachments/assets/d2651d55-6c48-496d-a2ab-bc4ae45fa111\" /\u003e\n\nFor a one-line summary, use `-1`:\n\n\u003cimg width=\"532\" height=\"65\" alt=\"image\" src=\"https://github.com/user-attachments/assets/7bac54e5-4288-4f86-b645-bf0ad2f4864f\" /\u003e\n\n### Flags\n\n| Flag | Default | What it does |\n| ------ | --------- | -------------- |\n| `--max-offset` | `5sec` | Allowed drift before the clock is marked out of sync |\n| `--max-rtt` | `2sec` | Network latency cutoff. Above this, the check is flagged as unreliable |\n| `--one-line` `-1` | (none) | Single-line output: `IN SYNC  14:32:07 → 14:32:07  312ms` |\n| `--raw` `-r` | (none) | Returns a raw record instead of text. Best for scripting. |\n\n### Scripting\n\n```nushell\ntime-sync --raw | if not $in.synced { print \"Clock drift detected!\" }\n```\n\nThe `--raw` flag returns a record with these fields: `local`, `network`, `drift`, `rtt`, `synced`, `reliable`, `timezone`.\n\n## How it works\n\n1. Records the time before and after the API call to measure round-trip latency.\n2. Pulls UTC time from `https://time.now/developer/api/ip`.\n3. Compares the network time to your local time.\n4. Reports the drift, RTT, and sync status.\n\nIf the network is slow (RTT above `--max-rtt`), the script flags the result as unreliable. High latency inflates the apparent drift, so a slow API response doesn't actually mean your clock is wrong.\n\n## Requirements\n\n- [Nushell](https://www.nushell.sh/)\n- Internet access\n\n## Notes\n\n- The script uses optional cell paths (`?`) to parse the API response. If the API changes its JSON shape slightly, the script shouldn't crash.\n- Network errors surface as clean messages instead of raw Nu stack traces.\n\n[World Time API by Time.Now](https://time.now)\n","funding_links":[],"categories":["Scripts"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSuaveIV%2Fnu_script_time_sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSuaveIV%2Fnu_script_time_sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSuaveIV%2Fnu_script_time_sync/lists"}