{"id":34130654,"url":"https://github.com/ynori7/datesforhumans","last_synced_at":"2026-03-11T12:22:25.410Z","repository":{"id":181504565,"uuid":"666868768","full_name":"ynori7/datesforhumans","owner":"ynori7","description":"This library is a helper to transform natural language date time info into real times.","archived":false,"fork":false,"pushed_at":"2023-07-21T15:31:51.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-09-05T03:05:27.051Z","etag":null,"topics":["dates","datetime","golang","natural-language","natural-language-processing","parser","time","utility"],"latest_commit_sha":null,"homepage":"","language":"Go","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/ynori7.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}},"created_at":"2023-07-15T21:20:18.000Z","updated_at":"2023-08-07T12:05:35.000Z","dependencies_parsed_at":"2023-07-15T22:38:16.173Z","dependency_job_id":null,"html_url":"https://github.com/ynori7/datesforhumans","commit_stats":null,"previous_names":["ynori7/datesforhumans"],"tags_count":1,"template":null,"template_full_name":null,"purl":"pkg:github/ynori7/datesforhumans","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynori7%2Fdatesforhumans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynori7%2Fdatesforhumans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynori7%2Fdatesforhumans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynori7%2Fdatesforhumans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ynori7","download_url":"https://codeload.github.com/ynori7/datesforhumans/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynori7%2Fdatesforhumans/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30380937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: 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":["dates","datetime","golang","natural-language","natural-language-processing","parser","time","utility"],"created_at":"2025-12-15T00:35:20.326Z","updated_at":"2026-03-11T12:22:25.402Z","avatar_url":"https://github.com/ynori7.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dates For Humans\nThis library is a helper to transform natural language date time info into real times. \n\nThe original usecase for this library was a requirement to have simple configuration in a config file for date patterns (e.g. to represent \"every monday\"). This allowed me to make the date patterns configurable in a simple human-readable way, thereby avoiding hardcoded logic. This project has since grown into a fully-fledged natural language parser for dates/times.\n\n## Usage\nYou can take any base time (e.g. `time.Now()`) and transform it using natural language. For example:\n\n- 10 minutes ago\n- 3 hours from now\n- next week\n- next monday\n- last September\n- this wednesday\n- in 15 seconds\n- next year\n- next monday at 10pm\n- today at noon\n- this july\n- july\n- monday\n- at 3pm\n\nExample usage (see it in `example/main.go`):\n\n### Basic Parsing\n\n```go\nnow := time.Now() //e.g. 2023-07-15 17:03:00\nt := datesforhumans.ParseDate(now, \"next monday\").At(\"10pm\").Time() //t is a standard time.Time\nfmt.Println(t.Format(time.DateTime)) //prints 2023-07-17 22:00:00\n\n//alternatively\nt2 := datesforhumans.ParseDate(now, \"next monday at 10pm\").Time() //t is a standard time.Time\nfmt.Println(t.Format(time.DateTime)) //prints 2023-07-17 22:00:00\n\n//or simply\nt3 := datesforhumans.FromNow(\"next monday at 10pm\").Time() //FromNow() is a shortcut for ParseDate(time.Now(), \"string\")\nfmt.Println(t.Format(time.DateTime)) //prints 2023-07-17 22:00:00\n```\n\n### Repeating\n\nThis pattern can also be repeated until a given date:\n\n```go\nrepeated := datesforhumans.ParseDate(now, \"next monday\").At(\"10pm\").Repeat(datesforhumans.ParseDate(now, \"next August\").Time())\nfor _, r := range repeated {\n    fmt.Println(r.Time().Format(time.DateTime))\n}\n// Prints:\n// 2023-07-17 22:00:00\n// 2023-07-24 22:00:00\n// 2023-07-31 22:00:00\n```\n\n### Ranges\n\nIt's also possible to create date ranges, for example:\n\n```go\nnow := time.Now() //e.g. 2023-07-15 17:03:00\nr := ParseRange(now, \"next monday at 10pm\", \"next tuesday at 11pm\")\nfmt.Println(r.Start.Time().Format(time.DateTime), \"-\", r.End.Time().Format(time.DateTime)) //prints 2023-07-17 22:00:00 - 2023-07-18 23:00:00\n```\n\nThe ranges can also automatically be repeated until a given date:\n\n```go\nrepeated := r.Repeat(datesforhumans.ParseDate(now, \"next August\").Time())\nfor _, r := range repeated {\n    fmt.Println(r.Start.Time().Format(time.DateTime), \"-\", r.End.Time().Format(time.DateTime))\n}\n// Prints:\n// 2023-07-17 22:00:00 - 2023-07-18 23:00:00\n// 2023-07-24 22:00:00 - 2023-07-25 23:00:00\n// 2023-07-31 22:00:00 - 2023-08-01 23:00:00\n```\n\n## Caveats\n- Note that if it's July 17 and you request \"next August\", you'll get August 1. However if you say \"in 1 month\" you'll get August 17. It's worth noting there are edge cases where it's January 30 and you say \"in 1 month\" (returns March 2nd).\n- If you give it a nonsensical input string, you'll get back the input time with the flag IsValid = false\n- This library assumes a week begins with Sunday (like stdlib \"time\" does). So when you ask for \"this sunday\" on a saturday, it'll return the previous sunday instead of tomorrow\n- If you say simply \"july\" or \"monday\", it assumes you mean \"this july\" or \"this monday\"\n- If you provide only a time (e.g. \"at 3pm\"), it assumes you mean \"today at 3pm\"","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fynori7%2Fdatesforhumans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fynori7%2Fdatesforhumans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fynori7%2Fdatesforhumans/lists"}