{"id":15657574,"url":"https://github.com/trstringer/go-systemd-time","last_synced_at":"2025-05-01T12:50:57.076Z","repository":{"id":57531555,"uuid":"131414433","full_name":"trstringer/go-systemd-time","owner":"trstringer","description":":date: Go implementation of systemd relative time adjustments","archived":false,"fork":false,"pushed_at":"2023-11-16T13:41:14.000Z","size":25,"stargazers_count":24,"open_issues_count":2,"forks_count":5,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-30T21:22:19.622Z","etag":null,"topics":["date","golang","systemd","time"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trstringer.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}},"created_at":"2018-04-28T14:02:08.000Z","updated_at":"2024-07-12T14:34:12.000Z","dependencies_parsed_at":"2023-11-16T14:43:27.610Z","dependency_job_id":"fd164a93-fa43-417c-bea0-2b3429c092f8","html_url":"https://github.com/trstringer/go-systemd-time","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fgo-systemd-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fgo-systemd-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fgo-systemd-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fgo-systemd-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trstringer","download_url":"https://codeload.github.com/trstringer/go-systemd-time/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251879117,"owners_count":21658690,"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":["date","golang","systemd","time"],"created_at":"2024-10-03T13:08:26.995Z","updated_at":"2025-05-01T12:50:57.037Z","avatar_url":"https://github.com/trstringer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-systemd-time\n\n![ci](https://github.com/trstringer/go-systemd-time/workflows/ci/badge.svg)\n\n_Go implementation of systemd time (`man systemd.time`)_\n\nIn command line applications, it is convenient to use the notation since `-1day`, or in `5 hours`. This package takes that string (using systemd time specs) and converts it into `time.Duration`. There is also a helper function that can take the raw string time adjustment and a `time.Time` (or `nil` for `time.Now()`) object and apply the adjustment to immutably. See below for usage.\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/trstringer/go-systemd-time/pkg/systemdtime\"\n)\n\nfunc main() {\n\tnow := time.Now()\n\ttimeFormat := \"3:04 PM on January 2, 2006\"\n\n\tfmt.Printf(\"Now is %s\\n\", now.Format(timeFormat))\n\n\tadjustedTime, err := systemdtime.AdjustTime(now, \"2d\")\n\tif err != nil {\n\t\tfmt.Printf(\"error adjusting time: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\tfmt.Printf(\"Adjusted is %s\\n\", adjustedTime.Format(timeFormat))\n\t/*\n\t   Now is 8:38 PM on September 30, 2020\n\t   Adjusted is 8:38 PM on October 2, 2020\n\t*/\n}\n```\n\n## Bug reports and running tests\n\nIf a bug is found, please write a failing test to uncover the bug.\n\nTo run tests, navigate to the root directory and run `go test -v ./...`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrstringer%2Fgo-systemd-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrstringer%2Fgo-systemd-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrstringer%2Fgo-systemd-time/lists"}