{"id":31812678,"url":"https://github.com/stynh/styme","last_synced_at":"2026-01-20T16:55:19.477Z","repository":{"id":317893839,"uuid":"1068337508","full_name":"StynH/STYME","owner":"StynH","description":"A zero-dependency library that allows for manipulating dates and times using natural language.","archived":false,"fork":false,"pushed_at":"2025-10-03T17:03:26.000Z","size":138,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-03T19:08:35.958Z","etag":null,"topics":["date","datetime","datetime-library","natural-language","time"],"latest_commit_sha":null,"homepage":"","language":"C#","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/StynH.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2025-10-02T08:24:11.000Z","updated_at":"2025-10-03T17:03:29.000Z","dependencies_parsed_at":"2025-10-06T10:17:00.549Z","dependency_job_id":null,"html_url":"https://github.com/StynH/STYME","commit_stats":null,"previous_names":["stynh/styme"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/StynH/STYME","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StynH%2FSTYME","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StynH%2FSTYME/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StynH%2FSTYME/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StynH%2FSTYME/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StynH","download_url":"https://codeload.github.com/StynH/STYME/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StynH%2FSTYME/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006602,"owners_count":26084130,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","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":["date","datetime","datetime-library","natural-language","time"],"created_at":"2025-10-11T07:21:38.869Z","updated_at":"2026-01-20T16:55:19.473Z","avatar_url":"https://github.com/StynH.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# ![Icon](logo.png) \n![NuGet Version](https://img.shields.io/nuget/v/STYME) ![NuGet Downloads](https://img.shields.io/nuget/dt/STYME)\n\nSTYME is a lightweight, zero-dependency C# library for parsing simple natural-language date/time expressions and applying them to a base date/time.\n\n## Usage Examples\n\n### Basic\n\n```csharp\nusing STYME;\n\n// By default NaturalDateTime uses the current system time as the base\nvar parser = new NaturalDateTime();\nvar result = parser.Parse(\"add 2 days\");\nConsole.WriteLine(result);\n```\n\nOutput (example):\n\n```\n2025-10-04T14:23:00\n```\n\nYou can parse expressions relative to a specific `DateTime` using `NaturalDateTime.From`.\n\n```csharp\nusing STYME;\n\nvar baseTime = new DateTime(2020, 1, 1, 0, 0, 0);\nvar parser = NaturalDateTime.From(baseTime);\nvar result = parser.Parse(\"add 1 month\");\nConsole.WriteLine(result);\n```\n\nOutput:\n\n```\n2020-02-01T00:00:00\n```\n\n### Add\n\nYou can add time using the `add` keyword.\n\n```csharp\nusing STYME;\n\nvar baseTime = new DateTime(2020, 3, 1, 12, 0, 0);\nvar parser = NaturalDateTime.From(baseTime);\nvar result = parser.Parse(\"add 1 year\");\nConsole.WriteLine(result);\n```\n\nOutput:\n\n```\n2021-03-01T00:00:00\n```\n\n\n### Deduct / Subtract\n\nYou can subtract time using the `deduct` (or `subtract`) keyword.\n\n```csharp\nusing STYME;\n\nvar baseTime = new DateTime(2020, 3, 1, 12, 0, 0);\nvar parser = NaturalDateTime.From(baseTime);\nvar result = parser.Parse(\"deduct 1 month\");\nConsole.WriteLine(result);\n```\n\nOutput:\n\n```\n2020-02-01T12:00:00\n```\n\n### Chaining operations\n\nYou can chain multiple operations using `and`.\n\n```csharp\nusing STYME;\n\nvar baseTime = new DateTime(2020, 1, 1, 0, 0, 0);\nvar parser = NaturalDateTime.From(baseTime);\nvar result = parser.Parse(\"add 3 days and deduct 5 hours\");\nConsole.WriteLine(result);\n```\n\nOutput:\n\n```\n2020-01-03T19:00:00\n```\n\n### Next\n\nUse `next` to jump to the upcoming occurrence of a day of the week or a month. The time of day is preserved.\n\n```csharp\nusing STYME;\n\nvar baseTime = new DateTime(2025, 1, 1, 8, 0, 0);\nvar parser = NaturalDateTime.From(baseTime);\nvar result = parser.Parse(\"next monday\");\nConsole.WriteLine(result);\n```\n\nOutput:\n\n```\n2025-01-06T08:00:00\n```\n\nThis operator can also be chained with the `and` operator.\n\n```csharp\nusing STYME;\n\nvar baseTime = new DateTime(2025, 1, 1, 8, 0, 0);\nvar parser = NaturalDateTime.From(baseTime);\nvar result = parser.Parse(\"next friday and add 2 hours\");\nConsole.WriteLine(result);\n```\n\nOutput:\n\n```\n2025-01-03T10:00:00\n```\n\n### End of week/month/year\n\nUse `end` to move to the end of the current week, month, or year. Fillers such as `of` and `the` are optional.\n\n```csharp\nusing STYME;\n\nvar baseTime = new DateTime(2025, 6, 15, 20, 45, 0);\nvar parser = NaturalDateTime.From(baseTime);\nvar result = parser.Parse(\"end of the month\");\nConsole.WriteLine(result);\n```\n\nOutput:\n\n```\n2025-06-30T20:45:00\n```\n\n### Recurring schedules\n\nYou can generate a lazy sequence of future dates using `every`. The sequence is infinite, so add your own break condition.\n\n```csharp\nusing STYME;\n\nvar baseTime = new DateTime(2025, 1, 1, 0, 0, 0);\nvar parser = NaturalDateTime.From(baseTime);\nvar schedule = parser.Enumerate(\"every 2 weeks\");\n\nforeach (var occurrence in schedule)\n{\n    Console.WriteLine(occurrence);\n    // Break when you reach the point you care about.\n    if (occurrence \u003e= new DateTime(2025, 2, 12))\n    {\n        break;\n    }\n}\n```\n\nOutput:\n\n```\n2025-01-01T00:00:00\n2025-01-15T00:00:00\n2025-01-29T00:00:00\n2025-02-12T00:00:00\n```\n\n### Supported units with `add` and `deduct`\n\nThe `add` and `deduct` expressions support the following units (singular and plural forms):\n\n- `second`, `seconds`\n- `minute`, `minutes`\n- `hour`, `hours`\n- `day`, `days`\n- `week`, `weeks`\n- `month`, `months`\n- `year`, `years`\n- `decade`, `decades`\n- `century`, `centuries`\n- `millennium`, `millennia`\n\nExample:\n\n```csharp\nusing STYME;\n\nvar parser = NaturalDateTime.From(new DateTime(2000, 1, 1));\nConsole.WriteLine(parser.Parse(\"add 2 decades\")); // 2020-01-01\nConsole.WriteLine(parser.Parse(\"deduct 1 century\")); // 1900-01-01\n```\n\n### Todo\n\n* [x] Add month support (set DateTime to specific month)\n* [x] Add day support (i.e. \"next friday\")\n* [ ] Add complex time support (i.e. \"quarter past five\")\n* [ ] Add multiple complex operations (i.e. \"add one year then next friday\")\n\n## Support\n\n* .NET 8.0 and later\n\n## License\n\nSTYME is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstynh%2Fstyme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstynh%2Fstyme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstynh%2Fstyme/lists"}