{"id":26822576,"url":"https://github.com/yoshihitoh/ut-cli","last_synced_at":"2025-06-26T19:35:29.332Z","repository":{"id":34997784,"uuid":"192747649","full_name":"yoshihitoh/ut-cli","owner":"yoshihitoh","description":"A command line tool to handle a unix timestamp.","archived":false,"fork":false,"pushed_at":"2023-04-13T20:57:43.000Z","size":171,"stargazers_count":21,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T22:36:09.850Z","etag":null,"topics":["cli","command-line","command-line-tool","rust","rust-lang","rust-tools","unixtime","unixtimeconverter","unixtimestamp"],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/yoshihitoh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","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":"2019-06-19T14:23:46.000Z","updated_at":"2025-04-03T02:00:20.000Z","dependencies_parsed_at":"2025-04-25T08:45:38.945Z","dependency_job_id":"dca089ae-b8dc-49fe-adf0-5ef9fa2256e6","html_url":"https://github.com/yoshihitoh/ut-cli","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshihitoh%2Fut-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshihitoh%2Fut-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshihitoh%2Fut-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshihitoh%2Fut-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoshihitoh","download_url":"https://codeload.github.com/yoshihitoh/ut-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250926213,"owners_count":21508917,"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":["cli","command-line","command-line-tool","rust","rust-lang","rust-tools","unixtime","unixtimeconverter","unixtimestamp"],"created_at":"2025-03-30T08:19:00.813Z","updated_at":"2025-04-26T10:44:49.501Z","avatar_url":"https://github.com/yoshihitoh.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"ut\n----\n\nut is a command line tool to handle a unix timestamp.\n\n[![Latest Version](https://img.shields.io/crates/v/ut-cli.svg)](https://crates.io/crates/ut-cli)\n![ci](https://github.com/yoshihitoh/ut-cli/workflows/ci/badge.svg)\n![Dependabot](https://api.dependabot.com/badges/status?host=github\u0026repo=yoshihitoh/ut-cli)\n\n### Motivation\nThere is a number of times to generate/parse unix timestamps.\nI think `date` command exists to handle these situations. But there are a few problems that they are small, but vital for me.\n- cannot use same options between macOS and Linux.\n- hard to remember usage. (it might be happen because of above problem.)\n\nThat's why I made a new command line tool `ut-cli`.\n\nI hope ut-cli works well when developers need to use the command which requires timestamps like aws-cli.\n\n### Example usage\n\nSearch logs from specific time period.\n``` bash\n# from yesterday to today\n$ aws logs filter-log-events \\\n    --log-group-name \u003cLOG_GROUP_NAME\u003e \\\n    --log-stream-names \u003cLOG_STREAM_NAMES\u003e \\\n    --query \u003cQUERY\u003e \\\n    --start-time $(ut -p ms g -b yesterday) \\\n    --end-time $(ut -p ms g -b today)\n```\n\n### Installation\n\nIf you have rust toolchain, ut-cli can be installed with cargo.\n``` bash\n$ cargo install ut-cli\n```\n\nor clone the repository and build it.\n\n``` bash\n$ git clone https://github.com/yoshihitoh/ut-cli\n$ cd ut-cli\n$ cargo build --release\n$ ./target/release/ut --version\nut 0.1.7\n```\n\nAlso there are pre-built binary for Linux, macOS and Windows.\nSee [releases](https://github.com/yoshihitoh/ut-cli/releases).\n\n### Usage\n``` bash\nut-cli 0.1.7\nyoshihitoh \u003cyoshihito.arih@gmail.com\u003e\nA command line tool to handle unix timestamp.\n\nUSAGE:\n    ut [FLAGS] [OPTIONS] \u003cSUBCOMMAND\u003e\n\nFLAGS:\n    -u, --utc        Use utc timezone.\n    -h, --help       Prints help information\n    -V, --version    Prints version information\n\nOPTIONS:\n    -o, --offset \u003cOFFSET\u003e          Use given value as timezone offset.\n    -p, --precision \u003cPRECISION\u003e\n            Set the precision of output timestamp.\n\n\nSUBCOMMANDS:\n    generate    Generate unix timestamp with given options.\n    help        Prints this message or the help of the given subcommand(s)\n    parse       Parse a unix timestamp and print it in human readable format.\n```\n\nYou can set options via envrionment variables.\n\n| name               | equiv option   | example \n|:------------------:|:--------------:|:-----------\n| UT_OFFSET          | -o/--offset    | 09:00\n| UT_PRECISION       | -p/--precision | millisecond\n| UT_DATETIME_FORMAT | -              | %Y-%m-%d %H:%M\n\nUT_DATETIME_FORMAT follows chrono's datetime specifiers.\nSee [the document](https://docs.rs/chrono/0.4.11/chrono/format/strftime/index.html) for details.\n\n```bash\n# Set variables.\n$ export UT_OFFSET='09:00'  # Use JST(+9).\n$ export UT_PRECISION=millisecond  # Use timestamps in milliseconds.\n\n# Generate a timestamp.\n$ ut g\n1588059756238\n\n# Parse a timestamp.\n$ echo 1588059756238 | ut p\n2020-04-28 16:42:36.238 (+09:00)\n\n# Change custom format and timezone.\n$ export UT_DATETIME_FORMAT=\"%m/%d/%Y\"\n$ echo 1588059756238 | ut --offset=-7 p\n04/28/2020\n```\n\nis equivalent to\n\n```bash\n$ ut -o '09:00' -p millisecond p $(ut -o '09:00' -p millisecond g)\n```\n\n\nThere are two subcommands available for now.\n- [generate(g)](#generate-a-unix-timestamp)\n- [parse(p)](#parse-a-unix-timestamp)\n\n#### Generate a unix timestamp\n\nGenerate a unix timestamp of the midnight of today.\n``` bash\n$ ut generate -b today\n1560870000\n\n# You can use `-p` option to show it in millisecond.\n$ ut -p ms generate -b today\n1560870000000\n```\n\nYou can specify time deltas with `-d` option.\n``` bash\n# 3days, 12hours, 30minutes later from the midnight of today.\n$ ut g -b today -d 3day -d 12hour -d 30minute\n1561174200\n\n# You can use short name on time unit.\n$ ut g -b today -d 3d -d 12h -d 30min\n1561174200\n\n# You can modify a timestamp with a timestamp argument.\n$ ut g -d 1min 1561174200\n1561174260    # 1min(=60second) difference.\n```\n\n#### Parse a unix timestamp\n\nParse a unix timestamp and print it in human readable format.\n``` bash\n$ ut p $(ut g -b today)\n2019-06-19 00:00:00 (+09:00)\n\n# You can parse timestamp in milliseconds.\n$ ut -p ms p $(ut -p ms g -b today -d 11h -d 22min -d 33s -d 444ms)\n2019-06-19 11:22:33.444 (+09:00)\n```\n\n#### Change timezone\n\n##### Local timezone\nIf you don't set timezone options, ut command uses local timezone.\n\nIn Japan(UTC+9):\n``` bash\n$ ut g --ymd 2019-06-24\n1561302000\n\n$ ut p 1561302000\n2019-06-24 00:00:00 (+09:00)\n```\n\nYou can use `-u` or `--utc` option to use UTC timezone.\n``` bash\n$ ut --utc p 1561302000\n2019-06-23 15:00:00 (UTC)\n```\n\nYou can use fixed offset timezone on any environment.\n``` bash\n# Generate PST timestamp\n$ ut -o -8 g --ymd 2019-06-24\n1561363200\n\n# Parse as PST timestamp\n$ ut -o -8 p 1561363200\n2019-06-24 00:00:00 (-08:00)\n\n# Parse as UTC timestamp\n$ ut -o 0 p 1561363200\n2019-06-24 08:00:00 (+00:00)\n```\n\n### TODO\n- Add more information on README\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoshihitoh%2Fut-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoshihitoh%2Fut-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoshihitoh%2Fut-cli/lists"}